PDA

View Full Version : right justify toolbar



magland
13th July 2007, 23:08
How can I get the widgets I add to QToolBar of a QMainWindow to be justified to the right?

marcel
14th July 2007, 16:47
You can try using QToolBar::layout()->setAlignment().
But I don't guarantee that it will work. It is just an assumption.

Regards

jpn
14th July 2007, 20:55
Or you could add a dummy widget (http://doc.trolltech.com/4.3/qtoolbar.html#addWidget) with QSizePolicy::Expanding in front.

magland
14th July 2007, 21:21
Or you could add a dummy widget (http://doc.trolltech.com/4.3/qtoolbar.html#addWidget) with QSizePolicy::Expanding in front.

Thanks, that did the trick. Much appreciated.

I did not try marcel's suggestion, but that may well have worked too... so thanks to both. :)

vycke
16th April 2008, 17:24
Or you could add a dummy widget (http://doc.trolltech.com/4.3/qtoolbar.html#addWidget) with QSizePolicy::Expanding in front.

I actually wound up using (on a QDialog, not QMainWindow):


m_vBoxLayout = new QVBoxLayout(this);
m_hBoxLayout = new QHBoxLayout();
m_vBoxLayout->addLayout(m_hBoxLayout);
m_vBoxLayout->addStretch(1);
m_hBoxLayout->insertStretch(0, 1);
m_hBoxLayout->addWidget(m_toolBar);


Which places my toolbar at the top/right of the dialog.

Vycke

jpn
16th April 2008, 18:36
I actually wound up using (on a QDialog, not QMainWindow):

Which places my toolbar at the top/right of the dialog.
But the original question was about aligning items IN the toolbar, not the toolbar itself. Furthermore, with QDialog you lose all the functionality QMainWindow has to offer for toolbars like ability to move toolbars.