Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

QMenu behaviour with QMainWindow/QGLWidget



  • Hi,

    I am working on an app and observed an odd behaviour with the menu. I wasn't sure if I'd done something to cause it so I reduced it to a simple form. My test case simply creates a QMainWindow, adds a QMenu named "File" with a single item to the menubar and sets the central widget to an empty QGLWidget.

    In this case the following occurs:

    1. "File" is pressed and the menu opens, as expected.
    2. "File" is pressed again and the menu closes, as expected.
    3. "File" is pressed again and nothing happens, not as expected.
    4. "File" is pressed again and the menu opens.

    This behaviour repeats where only every other press opens the menu. However, the following does appear to work as expected:

    1. "File" is pressed and the menu opens, as expected.
    2. The empty central widget is pressed and the menu closes, as expected.
    3. "File" is pressed again and the menu opens, as expected. Etc.

    If the central widget is swapped for a different widget (I tried a QPushButton), the menu works as I would expect, with each press opening and closing the menu in turn.

    Could someone please advise if there is there something extra I need to do when using a QGLWidget? Or is this not the expected behaviour?

    Thanks.


  • Lifetime Qt Champion

    Hi and welcome to devnet,

    Indeed, this is not the expected behavior. What OS/Qt combination are you running ?



  • Thanks.

    I'm using Qt Creator 3.0.1 (Qt 5.2.1) with Linux Mint 16 x64.


  • Lifetime Qt Champion

    Can you test if you have the same behavior with the latest 5.3 ?



  • I could only find 5.3.0 Alpha. Was that the one to test?

    I downloaded and built that. The result was the same as 5.2.1.


  • Lifetime Qt Champion

    Yes that's the one (there might also be the beta not far away)

    Anyway, you should check the "bug report system":http://bugreports.qt-project.org to see if it's something known. If not you should consider opening a new bug report providing a minimal compilable example that shows the behavior.



  • OK, I'll do that. Thanks for your help.


  • Lifetime Qt Champion

    You're welcome !

    If you open a bug report, please post a link here so other forum users may find it more easily if they encounter the same problem as you



  • I opened a new bug report "QTBUG-37720.":https://bugreports.qt-project.org/browse/QTBUG-37720

    Thanks.


Log in to reply