Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
I'm very new in Qt and I do not work with Qt, I would like only to learn for fun, but I have almost no time to research about my doubts (I have only some minutes per day) and my test program is progressing very slow. In order to increase developing speed I will ask some questions here. First, I would like to know how can I adjust width of a menu bar according the form size that this menu bar is inside. Does anybody could help me?
Thanks in advance,
Hareen Laks last edited by
I'm also new one to Qt.
According to my knowledge I think by default menubar width is set to the form width. isn't it?
qxoz last edited by
Show us your code.
The tool bar is adjustable by the minimumSize option etc. The icons, or text in the toolbar determine the size of the toolbar.
My mistake, you discussed the menuBar!!
The menuBar size is changeable with the font point size for example. The menuBar is resized with the contents just like the toolbar. Icons or text size determine the size of it.
Thanks for all answers.
I'm creating the QMenuBar at runtime, like this:
QMenuBar MenuObject = new QMenuBar(this);
where HeaderArea is QHLayoutBox.
Oke, the size of the QMenuBar can be set runtime, no problem, but if the answers where enough, mark this post as [SOLVED]
How can I do that a t runtime, could give me an example?
It seems that the QMenuBar width is by default according to parent widget size. My problem was that the QMenu inside the QMenuBar was in a different color in comparison of QMenuBar and QWidget. QMenu was gray and QWidget and QMenuBar were white. The result of this is that the QMenuBar finished at the middle of parent QWidget.
The code below shows the QMenuBar using all parent QWidget size as your own size, when the size of widget is changed by the user, QMenuBar size change too.
int main(int argc, char *argv)
QApplication app(argc, argv);
QWidget *x = new QWidget();
QMenuBar * q = new QMenuBar(x);
x->show(); return app.exec();
So, my problem is solved only changing the color of QMenu.