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

QToolButton and QToolBar actions' menus are shown on a wrong display

    XMLWordPrintable

Details

    • Bug
    • Resolution: Duplicate
    • P2: Important
    • None
    • 5.15.0
    • None
    • Gentoo Linux, KDE 5.18.5
    • Linux/X11

    Description

      I have 2 displays:

      1) laptop/primary 1920x1080 (left)

      2) hdmi/secondary 2560x1080 (right)

       

      And I have widgets based Qt-only application with a toolbar. Some actions added to the toolbar have menu.

      If I open this menu (by clicking the toolbar button) on the primary display it's shown properly. If I move the application window to the secondary display and click the toolbutton there, the menu is shown on the primiary display aligned to its right edge, while Y coordinate looks valid.

      This behavour doesn't depend on menu size. I have 3 affected to these problem menus implemented in different time / different ways but all of them are affected, one of them is very small (a couple of short items). One of the menus comes from a QToolButton being added right to the form instead of QToolBar.

      Even so any context menu for the same window or a menu I render manually menu->exec(QCursor::pos()); is shown in the correct position. Menus set to QPushButtons also work properly.

       

       Minimal reproducible example

      #include <QApplication>
      #include <QMenu>
      #include <QToolButton>
      
      int main(int argc, char **argv) {
        QApplication app(argc, argv);
        auto button = new QToolButton();
        button->setText("button");
        button->setPopupMode(QToolButton::InstantPopup);
        QMenu *menu = new QMenu(button);
        menu->addAction("item");
        button->setMenu(menu);
        button->show();
        return app.exec();
      }
       

       

      Attachments

        Issue Links

          No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

              qt.team.quick.subscriptions Qt Quick and Widgets Team
              rion Rion
              Votes:
              7 Vote for this issue
              Watchers:
              8 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes