I have created two QToolBar in the top of QMainWindow. Example:
But left tool bar has size according to its contents, and right tool bar stuck to left. Any combination with tool bars policy does not work.
Is there any way to stretch left tool bar ? May be exists some workaround ? Or it’s bug in framework ?
Thanks in advance.
Insert widget with QSizePolicy::Expanding into left toolbar using QToolBar::addWidget()
By the way, such convenience method as QToolBar::addStretch() would be nice. I’ve had this problem myself, some time ago.
Insert widget with QSizePolicy::Expanding into left toolbar using QToolBar::addWidget()…. I’ve had this problem myself, some time ago.
I tried this one and I saw this solution before, but in case with two bars on one line it doesn’t work.
Sorry, just forgot… Right bar has ‘RightToLeft’ layout direction.
If you want some widgets to be in the far right of the toolbar – just join two toolbar into one and insert that separator between actions of the two.
How I can join two toolbars ?
I need tool bar like Google Chorme bookmarks bar, where exist place for link buttons and one right button with menu (in chrome ‘other bookmarks’ tool button).
I tried almost everything and still no result.
Workaround exists, but requires a lot of extra work.
Dynamically updating tool bar contents will be trickery of another kind (that’s the hard part).
Solution with stretcher before button isn’t suitable because in case of toolbar overfill, the right button will be invisible. In my application this tool bar filled from item model and handle signals from model to overload.
I’ve tried dirty hack with overload resizeEvent in main window and set fixed width for toolbar dinamically, but behaviour also isn’t suitable because in time of resizng main window in some cases hangs.
So, do you have any other idea ? As I saw on other forums this problem not just for me.
Actually, maybe it’s not a bug but rather lack of feature. By default last toolbar get all the toolbar area space. And AFAIK there is no way to change that behavior.
If you remove setMovable(false) statements and try to drag that toolbar right, you will see it’s possible to do such a thing at the run time.
So how about trying not to resize toolbar in resizeEvent implementation but moving it?