Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Requires 2 right clicks to switch context menus among items?
Qt 6.11 is out! See what's new in the release blog

Requires 2 right clicks to switch context menus among items?

Scheduled Pinned Locked Moved General and Desktop
7 Posts 2 Posters 3.0k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    jaydenshui
    wrote on last edited by
    #1

    Code below with Qt 5.3.0 x64 opengl on windows 7

    @#include <QtWidgets>
    #include <QGLWidget>

    int main(int argc, char *argv[])
    {
    QApplication a(argc, argv);
    QMainWindow w;

    w.setCentralWidget(new QGLWidget(&w));
    
    QTreeWidget* tree = new QTreeWidget(&w);
    QTreeWidgetItem* item0 = 
        new QTreeWidgetItem(tree, QStringList("a"));
    QTreeWidgetItem* item1 = 
        new QTreeWidgetItem(tree, QStringList("b"));
    tree->setContextMenuPolicy(Qt::CustomContextMenu);
    QObject::connect(
        tree,
        &QTreeView::customContextMenuRequested,
        [&](){
            QMenu menu;
            menu.addAction("a");
            menu.exec&#40;QCursor::pos(&#41;&#41;;
    }&#41;;
    
    QDockWidget* dock = new QDockWidget("Tree", &w&#41;;
    dock->setWidget(tree&#41;;
    w.addDockWidget(Qt::LeftDockWidgetArea, dock&#41;;
    
    w.show(&#41;;
    return a.exec(&#41;;
    

    }@

    Compile and run it. It requires 2 right clicks to switch context menus among items. However, if I change QGLWidget to QWidget. It is fine. 1 right click can switch context menus among items. Any bugs??? Thanks a lot.

    Some observations: Switch the positions of the tree and the GL widget is ok, i.e. set the tree as the central widget and GL Widget as the one in the dock.

    More findings. When the widow is maximized. The issue is gone. When the widow is aligned with the left-top corner of the desktop screen, the issue is also gone. Thus, I think the bug is a mis-calculation of the mouse position when mapping to/from different widgets with dock widgets involved.

    Hope to see it corrected in the next Qt release.

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi and welcome to devnet,

      You should also add which version of Qt you are using as well as the OS you are running on

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • J Offline
        J Offline
        jaydenshui
        wrote on last edited by
        #3

        Thanks. Added. Qt 5.3.0 X64 OpenGL + Windows 7 64 bit

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          Can you test the same thing with 5.3.1 ?

          I can't reproduce it on OS X

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0
          • J Offline
            J Offline
            jaydenshui
            wrote on last edited by
            #5

            Try it on Qt5.3.1 widows 7 x64. Still has the same problem. :(

            1 Reply Last reply
            0
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #6

              You may have found something. You should check the "bug report system":http://bugreports.qt-project.org to see if it's something known. If not please consider opening a new report providing a minimal compilable project (your main + the corresponding pro file in a zip file)

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              1 Reply Last reply
              0
              • J Offline
                J Offline
                jaydenshui
                wrote on last edited by
                #7

                More findings. When the widow is maximized. The issue is gone. When the widow is aligned with the left-top corner of the desktop screen, the issue is also gone. Thus, I think the bug is a mis-calculation of the mouse position when mapping to/from different widgets with dock widgets involved.

                Hope to see it corrected in the next Qt release.

                1 Reply Last reply
                0

                • Login

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • Users
                • Groups
                • Search
                • Get Qt Extensions
                • Unsolved