Important: Please read the Qt Code of Conduct -

Mouse not working in custom widget

  • Hello,

    I am facing a problem where the mouse clicks are not working.

    I have a custom widget (let's call it widget A) which contains several objects such as buttons, sliders, line edit, etc. This widget A also contains a promoted widget which is a custom opengl widget (widget B) I have created.

    When the widget A is shown, the window is displayed and also the widget B is properly working. However, the mouse clicks on the buttons and other elements in widget A are not working. Moreover, the keyboard events are properly working and I can use the TAB key to switch between buttons, line edit, etc and I can even write text in the line edit. So it seems that widget works OK, but something is blocking the mouse for some reason (like a transparent layer or something). I am wondering if widget B has something to do with it.

    And here is one more thing. The mouse click on the X to close the widget A works. For that event, I have one window asking user if he/she wants to close the window. If I click "no", it gets back to the widget A and then the mouse works perfectly.

    Can someone guess why is not working when showing widget A the first time, but working after trying to close the window?

    Thank you in advance.

  • Lifetime Qt Champion

    I could't reproduce that with the latest Qt 5.4 code from git (compiled with MinGW and OpenGL desktop option)

  • I tested the example myself and it was giving the same error. When the window containing the opengl is open, are you able to click with the mouse both line edit widgets?

    I am using Qt 5.3.1, could it be a bug solved in qt 5.4 then?
    Do you have any chance to test it in an earlier version?

    If this was the reason, then I would try to update to 5.4, but it would take some time to update the projects and libraries that depend on Qt.

  • Lifetime Qt Champion

    Yes, I could edit both QLineEdits

  • I have just tried with latest version I found:

    And still the same problem. I can edit the QLineEdits with keyboard, but can't select them with the mouse.

Log in to reply