Creation of custom menubar.
-
Hello dear forum members,
there is a standard menubar (I can see it in Qt in design mode), but I need to customize it - add another element to the rightmost part. By default, only the buttons on the left can be inserted into the menubar one after the other.
What is the best way to do: create my own component with an imitation of menubar, or can I upgrade the standard component? And how can I do it?
Thank you in advance!
Happy New Year!)
-
@JonB I use Qt designer to construct my layout. And first UI element that I want to create is a menubar.
QMenuBar
let me includeQMenu
's, and they appear on the left side ofQMenuBar
line. But I want to add some additional info (kind of status info) in the right side ofQMenuBar
.
Here is what I mean:
@Asimo
Fair enough, I have never done that. Looks like you want to add an arbitrary widget, and have it placed over at the right-hand side. I don't know how easy it is to do that. I think https://stackoverflow.com/questions/8726677/aligning-qmenubar-items-add-some-on-left-and-some-on-right-side shows how to have some items at left and some at right (the accepted solution does it by two separate menu bars!). There is also https://stackoverflow.com/questions/14645596/stacking-qpushbuttons-on-the-other-side-of-a-qmenubar. Or Google for something likeqmenubar widget at right
--- I imagine you may not be the only person who wants this. -
Hello dear forum members,
there is a standard menubar (I can see it in Qt in design mode), but I need to customize it - add another element to the rightmost part. By default, only the buttons on the left can be inserted into the menubar one after the other.
What is the best way to do: create my own component with an imitation of menubar, or can I upgrade the standard component? And how can I do it?
Thank you in advance!
Happy New Year!)
-
@Asimo
I do not understand what you are saying cannot be added to the "rightmost" part yet can be inserted into the "leftmost" part? Given aQMenuBar
items can be inserted anywhere. What exactly would you like to do which you say cannot be done?@JonB I use Qt designer to construct my layout. And first UI element that I want to create is a menubar.
QMenuBar
let me includeQMenu
's, and they appear on the left side ofQMenuBar
line. But I want to add some additional info (kind of status info) in the right side ofQMenuBar
.
Here is what I mean:
-
@JonB I use Qt designer to construct my layout. And first UI element that I want to create is a menubar.
QMenuBar
let me includeQMenu
's, and they appear on the left side ofQMenuBar
line. But I want to add some additional info (kind of status info) in the right side ofQMenuBar
.
Here is what I mean:
@Asimo
Fair enough, I have never done that. Looks like you want to add an arbitrary widget, and have it placed over at the right-hand side. I don't know how easy it is to do that. I think https://stackoverflow.com/questions/8726677/aligning-qmenubar-items-add-some-on-left-and-some-on-right-side shows how to have some items at left and some at right (the accepted solution does it by two separate menu bars!). There is also https://stackoverflow.com/questions/14645596/stacking-qpushbuttons-on-the-other-side-of-a-qmenubar. Or Google for something likeqmenubar widget at right
--- I imagine you may not be the only person who wants this. -
@Asimo
Fair enough, I have never done that. Looks like you want to add an arbitrary widget, and have it placed over at the right-hand side. I don't know how easy it is to do that. I think https://stackoverflow.com/questions/8726677/aligning-qmenubar-items-add-some-on-left-and-some-on-right-side shows how to have some items at left and some at right (the accepted solution does it by two separate menu bars!). There is also https://stackoverflow.com/questions/14645596/stacking-qpushbuttons-on-the-other-side-of-a-qmenubar. Or Google for something likeqmenubar widget at right
--- I imagine you may not be the only person who wants this. -
@JonB Thank you! I just want to understand the principles of creating GUIs using Qt. I am a newbie in Qt and c++. And this first task made me stuck. I used Qt Designer and now I'm not sure that it is the right tool for my task. I will keep searching.
@Asimo
Well, for your first task you decided you wanted to place some arbitrary widget (at the right) on aQMenuBar
, which is simply not one of the features it offers; so one has to do some work to achieve that. I don't see why that in itself should reflect upon, or put you off, Qt Designer.Let's be clear: everything you can do in Designer you can do in code, just it's nicer to design/maintain visually. But not everything you can do in code can be done in Designer. You can mix & match bits of code produced from Designer with your own code to alter or augment it.
-
@Asimo
Well, for your first task you decided you wanted to place some arbitrary widget (at the right) on aQMenuBar
, which is simply not one of the features it offers; so one has to do some work to achieve that. I don't see why that in itself should reflect upon, or put you off, Qt Designer.Let's be clear: everything you can do in Designer you can do in code, just it's nicer to design/maintain visually. But not everything you can do in code can be done in Designer. You can mix & match bits of code produced from Designer with your own code to alter or augment it.