Which solution is best to resize QToolButton full-width?
-
I wanted same width and full-width QToolButtons but my phone abandoned me :(
First I thought set QSS to QToolButton with "width: 100%;" but it didn't be resized I wish. Then I thought some solutions like reimplementing QToolBar's resize event, using QWidgetAction with QPushButton, Inserting HBoxLayout to QToolbar and etc.
Umm... I guess better solution is exist, maybe. Any other solutions?
-
Sounds like your issue is also related to the request here:
"http://bugreports.qt.nokia.com/browse/QTBUG-13120":http://bugreports.qt.nokia.com/browse/QTBUG-13120
It's being worked on by the Qt team at the moment. If you have additional comments or suggestions, please post them as a comment to the report! -
We do think it is important (but not critical).
Note that you can easily set your QToolButtons inside QToolBars occupy fullwidth using sizepolicies.
For example:
@
QToolBar *toolbar = new QToolBar(this);
QToolButton *toolbutton = new QToolButton(this);
toolbutton->setText("ToolButton");
toolbutton->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Maximum);
toolbar ->addWidget(toolbutton);
toolbar ->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Maximum);
@Hopefully this helps.
Please follow the linked bug for additional information.
-
-
Yes, you are right. ToolBar uses layout to internally set the size of QAction derived buttons to "minimal".