-
Bug
-
Resolution: Unresolved
-
Not Evaluated
-
None
-
6.9, 6.10
The current QToolButton implementation does not look good when there is a menu:
It would be better to handle a QToolButton with a menu as a 'Split Button' as it already can distinguish between the label and the menu indicator through SC_ToolButton/SC_ToolButtonMenu (in contrast to a normal QPushButton, see also QTBUG-140145).
The menu indicator does also not match the WinUI3 style.
int main(int argc, char **argv) { QApplication app(argc, argv); QToolBar tb; auto a = new QAction("TB 1"); tb.addAction(a); a = new QAction(QIcon::fromTheme(QIcon::ThemeIcon::DocumentNew), "TB 2"); tb.addAction(a); a = new QAction("TB 3"); QMenu* menu = new QMenu; menu->addAction("Action 12345678901234567890"); a->setMenu(menu); tb.addAction(a); a = new QAction(QIcon::fromTheme(QIcon::ThemeIcon::DocumentNew), "TB 4"); tb.addAction(a); menu = new QMenu; menu->addAction("Action 12345678901234567890"); a->setMenu(menu); tb.setToolButtonStyle(Qt::ToolButtonIconOnly); //tb.setToolButtonStyle(Qt::ToolButtonTextBesideIcon); //tb.setToolButtonStyle(Qt::ToolButtonTextUnderIcon); tb.show(); return app.exec(); }
It's even more funnier - the order of adding a QAction to the QToolBar matters if the popupMode is set to MenuButtonPopup or not. When the QAction already has a QMenu set, then it's MenuButtonPopup, otherwise it's only QStyleOptionToolButton::Arrow...
- relates to
-
QTBUG-140145 Windows11Style: adjust the QPushButton geometry
-
- Reported
-
For Gerrit Dashboard: QTBUG-140148 | ||||||
---|---|---|---|---|---|---|
# | Subject | Branch | Project | Status | CR | V |
675658,3 | QToolButton: always set to MenuButtonPopup when action has a menu | dev | qt/qtbase | Status: NEW | 0 | 0 |