Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-140148

Windows11Style: adjust the QToolButton geometry

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Not Evaluated Not Evaluated
    • None
    • 6.9, 6.10
    • Widgets: Styles
    • Windows

      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...

        1. screenshot-1.png
          3 kB
          Christian Ehrlicher
        For Gerrit Dashboard: QTBUG-140148
        # Subject Branch Project Status CR V

            chehrlic Christian Ehrlicher
            chehrlic Christian Ehrlicher
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:

                There is 1 open Gerrit change