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. Back to "sender()" analysis...
Qt 6.11 is out! See what's new in the release blog

Back to "sender()" analysis...

Scheduled Pinned Locked Moved Unsolved General and Desktop
4 Posts 3 Posters 616 Views 2 Watching
  • 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.
  • A Offline
    A Offline
    Anonymous_Banned275
    wrote on last edited by Anonymous_Banned275
    #1

    RTFM on "sender()" is a challenge...
    dumpObjectInfo(); returns "void" and outputs to "debug" ...?

    Any way to get it to output to real debug
    such as " text " - qDebug() << text ?

      QObject *RXobject = sender();
       RXobject->dumpObjectInfo(); 
    

    Addendum

    How can I fix this:

    /mnt/A_BT_DEC10/BT__PROGRAMS/A_JAN11/A_BT_LIBRARY/terminal_Bluetooth/mainwindow_Bluetooth_copy.cpp:3884: error: 'senderSignalIndex' is a protected member of 'QObject'
    mainwindow_Bluetooth_copy.cpp:3884:19: error: 'senderSignalIndex' is a protected member of 'QObject'
    int i = RXobject->senderSignalIndex();
                      ^
    /home/nov25-1/Qt/5.15.2/gcc_64/include/QtCore/qobject.h:435:9: note: can only access this member on an object of type 'MainWindow_Bluetooth'
        int senderSignalIndex() const;
            ^
    

    and why I cannot use it "inside " this function ?

    void   MainWindow_Bluetooth::processMenu(int index_submenu, int index_mainmenu)
    {
    #ifdef LAMBDA
        text = "TASK DEBUG connect... "; //connect
        text += Q_FUNC_INFO;
        text += QString::number(__LINE__);
        // move index to class !!!
        text += " main loop index_main ";
        text += QString::number(index_mainmenu);
        text += " embeded loop  index_sub ";
        text += QString::number(index_submenu);
        text += " main loop class passed index ";
        text += QString::number(index);
        qDebug() << text;
    #endif
        {// analyze indexes received block
    
            QObject *RXobject = sender();
            RXobject->dumpObjectInfo();
    **int i = RXobject->senderSignalIndex();**
    //        int SenderIndex = RXobject::​senderSignalIndex();
    
            //text = RXobject->dumpObjectInfo();
            text += Q_FUNC_INFO;
            qDebug() << text;
    //#ifdef LAMBDA
    
    Christian EhrlicherC A Axel SpoerlA 3 Replies Last reply
    0
    • A Anonymous_Banned275

      RTFM on "sender()" is a challenge...
      dumpObjectInfo(); returns "void" and outputs to "debug" ...?

      Any way to get it to output to real debug
      such as " text " - qDebug() << text ?

        QObject *RXobject = sender();
         RXobject->dumpObjectInfo(); 
      

      Addendum

      How can I fix this:

      /mnt/A_BT_DEC10/BT__PROGRAMS/A_JAN11/A_BT_LIBRARY/terminal_Bluetooth/mainwindow_Bluetooth_copy.cpp:3884: error: 'senderSignalIndex' is a protected member of 'QObject'
      mainwindow_Bluetooth_copy.cpp:3884:19: error: 'senderSignalIndex' is a protected member of 'QObject'
      int i = RXobject->senderSignalIndex();
                        ^
      /home/nov25-1/Qt/5.15.2/gcc_64/include/QtCore/qobject.h:435:9: note: can only access this member on an object of type 'MainWindow_Bluetooth'
          int senderSignalIndex() const;
              ^
      

      and why I cannot use it "inside " this function ?

      void   MainWindow_Bluetooth::processMenu(int index_submenu, int index_mainmenu)
      {
      #ifdef LAMBDA
          text = "TASK DEBUG connect... "; //connect
          text += Q_FUNC_INFO;
          text += QString::number(__LINE__);
          // move index to class !!!
          text += " main loop index_main ";
          text += QString::number(index_mainmenu);
          text += " embeded loop  index_sub ";
          text += QString::number(index_submenu);
          text += " main loop class passed index ";
          text += QString::number(index);
          qDebug() << text;
      #endif
          {// analyze indexes received block
      
              QObject *RXobject = sender();
              RXobject->dumpObjectInfo();
      **int i = RXobject->senderSignalIndex();**
      //        int SenderIndex = RXobject::​senderSignalIndex();
      
              //text = RXobject->dumpObjectInfo();
              text += Q_FUNC_INFO;
              qDebug() << text;
      //#ifdef LAMBDA
      
      Christian EhrlicherC Offline
      Christian EhrlicherC Offline
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Maybe reading some c++ basics will help here: https://www.w3schools.com/cpp/cpp_access_specifiers.asp

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      1 Reply Last reply
      1
      • A Anonymous_Banned275

        RTFM on "sender()" is a challenge...
        dumpObjectInfo(); returns "void" and outputs to "debug" ...?

        Any way to get it to output to real debug
        such as " text " - qDebug() << text ?

          QObject *RXobject = sender();
           RXobject->dumpObjectInfo(); 
        

        Addendum

        How can I fix this:

        /mnt/A_BT_DEC10/BT__PROGRAMS/A_JAN11/A_BT_LIBRARY/terminal_Bluetooth/mainwindow_Bluetooth_copy.cpp:3884: error: 'senderSignalIndex' is a protected member of 'QObject'
        mainwindow_Bluetooth_copy.cpp:3884:19: error: 'senderSignalIndex' is a protected member of 'QObject'
        int i = RXobject->senderSignalIndex();
                          ^
        /home/nov25-1/Qt/5.15.2/gcc_64/include/QtCore/qobject.h:435:9: note: can only access this member on an object of type 'MainWindow_Bluetooth'
            int senderSignalIndex() const;
                ^
        

        and why I cannot use it "inside " this function ?

        void   MainWindow_Bluetooth::processMenu(int index_submenu, int index_mainmenu)
        {
        #ifdef LAMBDA
            text = "TASK DEBUG connect... "; //connect
            text += Q_FUNC_INFO;
            text += QString::number(__LINE__);
            // move index to class !!!
            text += " main loop index_main ";
            text += QString::number(index_mainmenu);
            text += " embeded loop  index_sub ";
            text += QString::number(index_submenu);
            text += " main loop class passed index ";
            text += QString::number(index);
            qDebug() << text;
        #endif
            {// analyze indexes received block
        
                QObject *RXobject = sender();
                RXobject->dumpObjectInfo();
        **int i = RXobject->senderSignalIndex();**
        //        int SenderIndex = RXobject::​senderSignalIndex();
        
                //text = RXobject->dumpObjectInfo();
                text += Q_FUNC_INFO;
                qDebug() << text;
        //#ifdef LAMBDA
        
        A Offline
        A Offline
        Anonymous_Banned275
        wrote on last edited by
        #3

        @AnneRanch Here is my latest code , it seems to "navigate " up- stream as far as menus goes...

                QObject *RXobject = sender();
                RXobject->dumpObjectInfo();
                QObject *RXparent = RXobject->parent(); main "windows" menu 
                QObject *TEST_parent = RXparent->parent(); main mdiArea menu 
        
        1 Reply Last reply
        0
        • A Anonymous_Banned275

          RTFM on "sender()" is a challenge...
          dumpObjectInfo(); returns "void" and outputs to "debug" ...?

          Any way to get it to output to real debug
          such as " text " - qDebug() << text ?

            QObject *RXobject = sender();
             RXobject->dumpObjectInfo(); 
          

          Addendum

          How can I fix this:

          /mnt/A_BT_DEC10/BT__PROGRAMS/A_JAN11/A_BT_LIBRARY/terminal_Bluetooth/mainwindow_Bluetooth_copy.cpp:3884: error: 'senderSignalIndex' is a protected member of 'QObject'
          mainwindow_Bluetooth_copy.cpp:3884:19: error: 'senderSignalIndex' is a protected member of 'QObject'
          int i = RXobject->senderSignalIndex();
                            ^
          /home/nov25-1/Qt/5.15.2/gcc_64/include/QtCore/qobject.h:435:9: note: can only access this member on an object of type 'MainWindow_Bluetooth'
              int senderSignalIndex() const;
                  ^
          

          and why I cannot use it "inside " this function ?

          void   MainWindow_Bluetooth::processMenu(int index_submenu, int index_mainmenu)
          {
          #ifdef LAMBDA
              text = "TASK DEBUG connect... "; //connect
              text += Q_FUNC_INFO;
              text += QString::number(__LINE__);
              // move index to class !!!
              text += " main loop index_main ";
              text += QString::number(index_mainmenu);
              text += " embeded loop  index_sub ";
              text += QString::number(index_submenu);
              text += " main loop class passed index ";
              text += QString::number(index);
              qDebug() << text;
          #endif
              {// analyze indexes received block
          
                  QObject *RXobject = sender();
                  RXobject->dumpObjectInfo();
          **int i = RXobject->senderSignalIndex();**
          //        int SenderIndex = RXobject::​senderSignalIndex();
          
                  //text = RXobject->dumpObjectInfo();
                  text += Q_FUNC_INFO;
                  qDebug() << text;
          //#ifdef LAMBDA
          
          Axel SpoerlA Offline
          Axel SpoerlA Offline
          Axel Spoerl
          Moderators
          wrote on last edited by
          #4

          @AnneRanch said in Back to "sender()" analysis...:

          How can I fix this:

          sender()always returns a QObject *.
          If you want to access members of a class inheriting from QObject, e.g. MainWindow_Bluetooth, qobject_cast is your friend. It's documentation is here.

          Software Engineer
          The Qt Company, Oslo

          1 Reply Last reply
          1

          • Login

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