How to access MainWindow statusBar from a OpenGL glWidget mouse event?



  • Inside my "class glwidget : public QGLWidget, protected QGLFunctions" I want to call the MainWindow method "statusBar()->showMessage( cursor location)" as the cursor moves over an image in my mouseMoveEvent() method.

    I've tried passing the MainWindow instance down into the glwidget, but there are circular include problems - MainWindow.h includes glwidget.h, so I can't include mainwindow.h inside glwidget.h. I've tried playing with the Ui namespace, and after 3 hours I'm giving up.

    Is there an easy way to do this? I'll even try the difficult way ...

    Thanks


  • Moderators

    In your glwidget create a signal eg. signalMessage(QString msg) and emit it in the mouseMoveEvent().
    In your main window create a slot eg. showMessage(QString msg) that will output something in the status bar.
    Connect those two in your main window. That way you don't need to include anything in the glwidget.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.