PDA

View Full Version : QToolbar setContentsMargins



rshabsin
18th September 2007, 20:21
While trying to upgrade from Qt 4.1.2 to 4.3.1, I ran into a problem with my toolbar. I have two icons I always want to display all the way on the right of my toolbar like this: http://www.shabsin.com/~rshabsin/_uimages/efcttoolbar99.bmp, and I was able to do that in 4.1.2 by doing some calculations and then setting the contents margins on my rightmost toolbar (the one containing the two icons) so the left margin would be just the right size to position the icons all the way on the right. This doesn't seem to work in 4.3.1. I even tried getting the tool bar's layout and setting its contents margin, but that didn't work either, I always get this: http://www.shabsin.com/~rshabsin/_uimages/efcttoolbar98.bmp. Any help?

jpn
18th September 2007, 21:04
Try adding a dummy expanding widget as first item in the tool bar:


// a dummy expanding widget
QWidget* widget = new QWidget(toolBar);
widget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
toolBar->addWidget(widget);
// add real actions
tooBar->addAction(...);
...

rshabsin
18th September 2007, 22:12
wow, very simple - worked great. thx, jpn.