Solved Emit signal to parent
-
See below for answer
The QT widget contains a QGLWidget as inC_Strip_Chart::C_Strip_Chart( QWidget *parent ) :QMainWindow( parent ) { … Plotted_points = new C_GL_Strip_Chart( central_widget, this ); // the QGLWidget } …
Please try to accommodate types as I cannot copy paste to here. The Qt widget works fine and I can display data in the GL widget.
When some things in the GL widget change it is to notify the parent so a display can be updated. That GL widget looks like:C_GL_Strip_Chart:: C_GL_Strip_Chart( QWidget * parent, C_Strip_Chart * owner ) : QGLWidget( parent, “qglwidget” ) {… // I have tried a few permutations such as: connect( this, SIGNAL( send_time_changed( double), parent, SLOT( rcv_time_changed() ) ); }
The best I can get is no compiler errors but a run time message:
No such slot QWidget::rcv_time_changed()
What code can be written such that a subordinate or enclosed widget can emit a signal to its enclosing widget?
I have also tried passing “this” to the subordinate, saving it as “sent_pointer” then directly calling a function withsent_pointer->receiver( double )
That solicits the compile error:
Invalid use of incomplete type ‘class C_Strip_Chart’
EDIT: ANSWER
For some reason, head-up-the-buttitis, I don't know, I concluded that signals and slots should be connected from the SIGNAL perspective, the sender. I finally tried doing the connect from the SLOT perspective and it worked right away. Now to delete all those multiple variations that are cluttering up my code. :-) -
@BKBK just as note: connecting to a parent feels wrong. rather connect in the parent, as he already knows the child.
That leads to better reusable code.
-
@aha_1980 said in Emit signal to parent:
@BKBK just as note: connecting to a parent feels wrong. rather connect in the parent, as he already knows the child.
That leads to better reusable code.
Yes, good point.