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

Windows11Style: adjust the QPushButton geometry

XMLWordPrintable

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

      The following code shows the problem:

      int main(int argc, char **argv)
      {
          QApplication app(argc, argv);
          QWidget w;
          auto lay = new QHBoxLayout(&w);
          lay->addSpacerItem(new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Expanding));
          QPushButton pb1("Push me please!");
          QPushButton pb2(QIcon::fromTheme(QIcon::ThemeIcon::DocumentNew), "Push me please!");
          QPushButton pb3("Push me please!");
          QMenu* menu = new QMenu(&pb3);
          menu->addAction("Action 12345678901234567890");
          pb3.setMenu(menu);
          QPushButton pb4(QIcon::fromTheme(QIcon::ThemeIcon::DocumentNew), "Push me please!");
          menu = new QMenu(&pb4);
          menu->addAction("Action 12345678901234567890");
          pb4.setMenu(menu);
          lay->addWidget(&pb1); lay->addWidget(&pb2);lay->addWidget(&pb3);lay->addWidget(&pb4);
          lay->addSpacerItem(new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Expanding));
          w.show();
          return app.exec();
      }
      

      Output:

      A 'Split Button' is mimiced but we can't handle this (we would need different hover states for the text and the dropdown, it's a QToolButton feature) so we should use 'Dropdown' instead which has no separator. Also the dropdown icon is wrong (must be ChevronDownMed) and the whole geometry does not match wrt the horizontal margins.

      Fixed:

      One could argue that the height does still not match but this would break the height wrt to other widgets so leave it for now

        1. image-2025-09-13-11-24-34-370.png
          6 kB
          Christian Ehrlicher
        2. screenshot-1.png
          5 kB
          Christian Ehrlicher
        For Gerrit Dashboard: QTBUG-140145
        # 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