Which solution is best to resize QToolButton full-width?
-
wrote on 7 Sept 2010, 11:25 last edited by
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?
-
wrote on 7 Sept 2010, 19:26 last edited by
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! -
wrote on 8 Sept 2010, 05:03 last edited by
Thx ajkl. I have just commented.
Qt team doesn't think it is not so important. But I think it's very important issue for Symbian developers with Qt… :-/
-
wrote on 9 Sept 2010, 06:30 last edited by
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.
-
wrote on 10 Sept 2010, 01:07 last edited by
Thx for your help, Fuzzbender.
Your code works well but setSizePolicy() doesn't affect QToolButton that created through addAction() method.
I used setSizePolicy() in actionEvent() and resizeEvent() with QToolButton got by widgetForAction(). Am I worng?
-
wrote on 10 Sept 2010, 07:58 last edited by
Yes, you are right. ToolBar uses layout to internally set the size of QAction derived buttons to "minimal".
1/6