Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
How to access MainWindow statusBar from a OpenGL glWidget mouse event?
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 ...
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.