Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Update: Forum Guidelines & Code of Conduct

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

    General and Desktop
    2
    2
    1192
    Loading More Posts
    • 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.
    • P
      pmaynard last edited by

      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

      1 Reply Last reply Reply Quote 0
      • Chris Kawa
        Chris Kawa Moderators last edited by

        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.

        1 Reply Last reply Reply Quote 0
        • First post
          Last post