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

QToolButton menu selections fail to highlight when in QMdiSubwindow

    XMLWordPrintable

Details

    • All
    • 49f462b7f (dev), b33821736 (6.9), 034bc2fe1 (6.8)

    Description

      When using a QToolButton, whose parent is a QMdiSubwindow, I open a menu with many items in it by clicking on the tool button. The highlight of which item is selected fails in a geometry-dependent way. The only way I get an item selection is if the subwindow is all the way to the left of the MdiArea, and the tool button is towards the top of the subwindow. Even so, the highlight fails, or is only a partial highlight. This is completely dependent on the vertical position of the subwindow though, so it is inconsistent. Note, this is with the new Windows11 style. This isn't the case using WindowsVista style.

      Minimal code for reproducing:

      #include <QMenu>
      #include <QApplication>
      #include <QToolButton>
      #include <QMdiArea>
      #include <QMdiSubWindow>
      #include <QMainWindow>
      
      int main(int argc, char *argv[]){
          QApplication a(argc, argv);
          QMainWindow mdiWindow;
          QMdiArea mdiArea(&mdiWindow);
          mdiWindow.setCentralWidget(&mdiArea);
          QMainWindow w;
          QMdiSubWindow* subwindow = mdiArea.addSubWindow(&w);
          subwindow->setGeometry(50, 50, 300, 300);
          QToolButton toolButton(subwindow);
          toolButton.setGeometry(0, 30, 100, 20);
      
          QMenu menu(&toolButton);
          for (int i = 1; i <= 15; ++i)
              menu.addAction(new QAction(QString("This is item %1").arg(i)));
      
          toolButton.setPopupMode(QToolButton::InstantPopup);
          toolButton.setText("Options");
          toolButton.setMenu(&menu);
          mdiWindow.show();
          subwindow->show();
          return a.exec();
      }
      

       

      Example of highlight failing on item 8 and below:

      But if I move the subwindow slightly down, the highlight fails on a different item (item 6):

      These examples are with the subwindow all the way to the left of the mdiArea. If I move the subwindow more to the right, I can even get partial horizontal highlights:

      Attachments

        1. image-2024-12-04-10-21-22-576.png
          36 kB
          Benjamin Luke Murphy-Baum
        2. image-2024-12-04-10-21-39-212.png
          36 kB
          Benjamin Luke Murphy-Baum
        3. image-2024-12-04-10-22-39-256.png
          32 kB
          Benjamin Luke Murphy-Baum
        4. image-2024-12-04-10-24-24-407.png
          35 kB
          Benjamin Luke Murphy-Baum
        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            wladimir.leuschner Wladimir Leuschner
            bmbaum Benjamin Luke Murphy-Baum
            Votes:
            1 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes