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

Is a QWidget in a QStackedWidget not be able to receive MousePressEvent?



  • I want to pass a signal which is received by a QWidget in a QStackedWidget to QMainWindow (which would be the parent of QStackedWidget).
    However, it seems that the QWidget does not receive the MousePressEvent because this simple code doesn't work.

    void Content::mousePressEvent(QMouseEvent*){
           std::cout << "test\n";
    }
    

    How should I manage to QStackwidget in terms of a signal?


  • Lifetime Qt Champion

    @Aaron-Kim Is the widget visible and the one you actually click?


  • Qt Champions 2017

    Can you show the sample code piece ? Did you the stack widget as central widget in mainwindow object or just passed the mainwindow object as parent to stack widget ? In general as @jsulm said, if the widget is visible through stack widget it should recv the mouse press events.


Log in to reply