Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Emit signal to parent
Forum Updated to NodeBB v4.3 + New Features

Emit signal to parent

Scheduled Pinned Locked Moved Solved General and Desktop
3 Posts 2 Posters 1.7k Views
  • 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.
  • B Offline
    B Offline
    BKBK
    wrote on last edited by BKBK
    #1

    See below for answer
    The QT widget contains a QGLWidget as in

    C_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 with

    sent_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. :-)

    aha_1980A 1 Reply Last reply
    0
    • B BKBK

      See below for answer
      The QT widget contains a QGLWidget as in

      C_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 with

      sent_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. :-)

      aha_1980A Offline
      aha_1980A Offline
      aha_1980
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @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.

      Qt has to stay free or it will die.

      B 1 Reply Last reply
      2
      • aha_1980A aha_1980

        @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.

        B Offline
        B Offline
        BKBK
        wrote on last edited by
        #3

        @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.

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved