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. How to "trigger" from check bpx...?
Forum Updated to NodeBB v4.3 + New Features

How to "trigger" from check bpx...?

Scheduled Pinned Locked Moved Unsolved General and Desktop
8 Posts 5 Posters 501 Views 3 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

    Sorry for posting so many issues , but I like to keep each one separately.

    I am making slow progress with my "menu/submenu" task.

    Here is my current code:
    I have have highlighted area I need help.

    I need help with putting correct 'trigger" code in

    SIGNAL

        for (int index = 0; index < list.size(); ++index)
        {
    #ifdef DEBUG_MDI
            text = Q_FUNC_INFO;
            text += "  @ line  ";
            text += QString::number(__LINE__);
            text += "  TASK   run for loop !!!!!!!!!!!!!!!";
            //text += QString::number(index);
            qDebug() << text;
    #endif
            tempmenu = new QMenu();
            tempmenu->setTitle(list[index] + " #" + QString::number(index));
            subMenu[index]  = m_ui->menuWindow_cpntrol;
            subAction[index] = subMenu[index]->addMenu(tempmenu);
            subAction[index]->setVisible(true);
            subAction[index]->setCheckable(true);
            qDebug() << list[index];
            //list_hcitool
            // temporary switch here
            switch(index)
            { // switch
            case 0:
            {
                { //process
    
                }//process
                break;
            }
            case 1:
            {
                { //process
                    for (int index = 0; index < list_hcitool.size(); ++index)
                    {
                        text = "Add subsubmenu";
                        subtempmenu = new QMenu();
                        subtempmenu->setTitle(list_hcitool[index] + " #" + QString::number(index));
                        subMenu[index]  = tempmenu; //m_ui->menuWindow_cpntrol;
                        subAction[index] = subMenu[index]->addMenu(subtempmenu);
                        subAction[index]->setVisible(true);
                        **subAction[index]->setCheckable(true);
    this adds check box to the menu TOK**
    
    
    subAction[index]->triggered(true);
                        qDebug() << list_hcitool[index];
    
                        // connect here ??
                        //     for (int index = 0; index < list.size(); ++index)
                            {
                        #ifdef DEBUG_MDI
                                text = Q_FUNC_INFO;
                                text += "  @ line  ";
                                text += QString::number(__LINE__);
                                text += "  TASK   run for loop !!!!!!!!!!!!!!!";
                                //text += QString::number(index);
                                qDebug() << text;
                        #endif
                                tempmenu = new QMenu();
                                tempmenu->setTitle(list[index] + " #" + QString::number(index));
                                subMenu[index]  = m_ui->menuWindow_cpntrol;
                                subAction[index] = subMenu[index]->addMenu(tempmenu);
                                subAction[index]->setVisible(true);
                                subAction[index]->setCheckable(true);
                                qDebug() << list[index];
                                //list_hcitool
                                // temporary switch here
                                switch(index)
                                { // switch
                                case 0:
                                {
                                    { //process
                        
                                    }//process
                                    break;
                                }
                                case 1:
                                {
                                    { //process
                                        for (int index = 0; index < list_hcitool.size(); ++index)
                                        {
                                            text = "Add subsubmenu";
                                            subtempmenu = new QMenu();
                                            subtempmenu->setTitle(list_hcitool[index] + " #" + QString::number(index));
                                            subMenu[index]  = tempmenu; //m_ui->menuWindow_cpntrol;
                                            subAction[index] = subMenu[index]->addMenu(subtempmenu);
                                            subAction[index]->setVisible(true);
                                            subAction[index]->setCheckable(true);
                        subAction[index]->triggered(true);
                                            qDebug() << list_hcitool[index];
                        
                                            // connect here ??
                                            // keeps accessing the slot
                                            connect(subAction[index],
                                                    **SIGNAL(hovered()),
                                            **keeps accessing the slot
                                         need "single shot"
                                       fix in SLOT ?**
                                                   this,SLOT(testSlot()));**
                                            // TODO  triggerd by check box
                                            //connect(subAction[index],SIGNAL(subAction[index]->triggered(true))),
                                            //        this,SLOT(testSlot());
                                        }
                                    }//process
                                    break;
                        connect(subAction[index],
                                SIGNAL(hovered()),
    SIGNAL(hovered()),
    
    
                                this,SLOT(testSlot()));
    
    
                        // TODO  triggerd by check box
           connect(subAction[index],SIGNAL(subAction[index]->triggered(true))),
                                                    this,SLOT(testSlot());                    //connect(subAction[index],SIGNAL(subAction[index]->triggered(true))),
                        //        this,SLOT(testSlot());
                    }
                }//process
                break;
    

    :

    Pl45m4P 1 Reply Last reply
    0
    • A Anonymous_Banned275

      Sorry for posting so many issues , but I like to keep each one separately.

      I am making slow progress with my "menu/submenu" task.

      Here is my current code:
      I have have highlighted area I need help.

      I need help with putting correct 'trigger" code in

      SIGNAL

          for (int index = 0; index < list.size(); ++index)
          {
      #ifdef DEBUG_MDI
              text = Q_FUNC_INFO;
              text += "  @ line  ";
              text += QString::number(__LINE__);
              text += "  TASK   run for loop !!!!!!!!!!!!!!!";
              //text += QString::number(index);
              qDebug() << text;
      #endif
              tempmenu = new QMenu();
              tempmenu->setTitle(list[index] + " #" + QString::number(index));
              subMenu[index]  = m_ui->menuWindow_cpntrol;
              subAction[index] = subMenu[index]->addMenu(tempmenu);
              subAction[index]->setVisible(true);
              subAction[index]->setCheckable(true);
              qDebug() << list[index];
              //list_hcitool
              // temporary switch here
              switch(index)
              { // switch
              case 0:
              {
                  { //process
      
                  }//process
                  break;
              }
              case 1:
              {
                  { //process
                      for (int index = 0; index < list_hcitool.size(); ++index)
                      {
                          text = "Add subsubmenu";
                          subtempmenu = new QMenu();
                          subtempmenu->setTitle(list_hcitool[index] + " #" + QString::number(index));
                          subMenu[index]  = tempmenu; //m_ui->menuWindow_cpntrol;
                          subAction[index] = subMenu[index]->addMenu(subtempmenu);
                          subAction[index]->setVisible(true);
                          **subAction[index]->setCheckable(true);
      this adds check box to the menu TOK**
      
      
      subAction[index]->triggered(true);
                          qDebug() << list_hcitool[index];
      
                          // connect here ??
                          //     for (int index = 0; index < list.size(); ++index)
                              {
                          #ifdef DEBUG_MDI
                                  text = Q_FUNC_INFO;
                                  text += "  @ line  ";
                                  text += QString::number(__LINE__);
                                  text += "  TASK   run for loop !!!!!!!!!!!!!!!";
                                  //text += QString::number(index);
                                  qDebug() << text;
                          #endif
                                  tempmenu = new QMenu();
                                  tempmenu->setTitle(list[index] + " #" + QString::number(index));
                                  subMenu[index]  = m_ui->menuWindow_cpntrol;
                                  subAction[index] = subMenu[index]->addMenu(tempmenu);
                                  subAction[index]->setVisible(true);
                                  subAction[index]->setCheckable(true);
                                  qDebug() << list[index];
                                  //list_hcitool
                                  // temporary switch here
                                  switch(index)
                                  { // switch
                                  case 0:
                                  {
                                      { //process
                          
                                      }//process
                                      break;
                                  }
                                  case 1:
                                  {
                                      { //process
                                          for (int index = 0; index < list_hcitool.size(); ++index)
                                          {
                                              text = "Add subsubmenu";
                                              subtempmenu = new QMenu();
                                              subtempmenu->setTitle(list_hcitool[index] + " #" + QString::number(index));
                                              subMenu[index]  = tempmenu; //m_ui->menuWindow_cpntrol;
                                              subAction[index] = subMenu[index]->addMenu(subtempmenu);
                                              subAction[index]->setVisible(true);
                                              subAction[index]->setCheckable(true);
                          subAction[index]->triggered(true);
                                              qDebug() << list_hcitool[index];
                          
                                              // connect here ??
                                              // keeps accessing the slot
                                              connect(subAction[index],
                                                      **SIGNAL(hovered()),
                                              **keeps accessing the slot
                                           need "single shot"
                                         fix in SLOT ?**
                                                     this,SLOT(testSlot()));**
                                              // TODO  triggerd by check box
                                              //connect(subAction[index],SIGNAL(subAction[index]->triggered(true))),
                                              //        this,SLOT(testSlot());
                                          }
                                      }//process
                                      break;
                          connect(subAction[index],
                                  SIGNAL(hovered()),
      SIGNAL(hovered()),
      
      
                                  this,SLOT(testSlot()));
      
      
                          // TODO  triggerd by check box
             connect(subAction[index],SIGNAL(subAction[index]->triggered(true))),
                                                      this,SLOT(testSlot());                    //connect(subAction[index],SIGNAL(subAction[index]->triggered(true))),
                          //        this,SLOT(testSlot());
                      }
                  }//process
                  break;
      

      :

      Pl45m4P Offline
      Pl45m4P Offline
      Pl45m4
      wrote on last edited by Pl45m4
      #2

      @AnneRanch said in How to "trigger" from check bpx...?:

      connect(subAction[index],SIGNAL(subAction[index]->triggered(true))),
      this,SLOT(testSlot());

      Dont know what exactly you are doing, but the correct connection would look like this:

      connect(subAction[index], SIGNAL(triggered(bool))), this, SLOT(testSlot(bool)); 
      // OR
      connect(subAction[index], &QAction::triggered, this, &WHATEVER_CLASS_YOU_ARE_IN::testSlot); 
      
      

      You could easily solve these kind of "issues" yourself, if you would look at the documentation.
      Signals are listed here:

      • https://doc.qt.io/qt-6/qaction.html#signals

      and triggered(bool checkstate) is explained here:

      • https://doc.qt.io/qt-6/qaction.html#triggered

      If debugging is the process of removing software bugs, then programming must be the process of putting them in.

      ~E. W. Dijkstra

      Axel SpoerlA 1 Reply Last reply
      2
      • A Offline
        A Offline
        Anonymous_Banned275
        wrote on last edited by
        #3

        Could some kind person - without need to know what I am doing or without reference to RTFM kindly explain the difference between "connect"
        ?

        { //process
                        for (int index = 0; index < list_hcitool.size(); ++index)
                        {
                            text = "Add subsubmenu";
                            subtempmenu = new QMenu();
                            subtempmenu->setTitle(list_hcitool[index] + " #" + QString::number(index));
                            subMenu[index]  = tempmenu; //m_ui->menuWindow_cpntrol;
                            subAction[index] = subMenu[index]->addMenu(subtempmenu);
                            subAction[index]->setVisible(true);
                            subAction[index]->setCheckable(true);
        subAction[index]->triggered(true);
                            qDebug() << list_hcitool[index];
        **THIS connect runs testSlot
                            // connect here ??
        //                    connect(subAction[index],
        //                           SIGNAL(hovered()),
        //                           this,SLOT(testSlot()));**
        
        
        **THIS ONE DOES NOT 
                            connect(
                                    subAction[index],
                                    SIGNAL(triggered()),
                                    this,
                                    SLOT(testSlot()));
        
        ```**
        
        
        
        My guess - the SIGNAL "triggered"  code is missing something.
        
        
        Thanks for your help.
        J.HilkJ 1 Reply Last reply
        0
        • Pl45m4P Pl45m4

          @AnneRanch said in How to "trigger" from check bpx...?:

          connect(subAction[index],SIGNAL(subAction[index]->triggered(true))),
          this,SLOT(testSlot());

          Dont know what exactly you are doing, but the correct connection would look like this:

          connect(subAction[index], SIGNAL(triggered(bool))), this, SLOT(testSlot(bool)); 
          // OR
          connect(subAction[index], &QAction::triggered, this, &WHATEVER_CLASS_YOU_ARE_IN::testSlot); 
          
          

          You could easily solve these kind of "issues" yourself, if you would look at the documentation.
          Signals are listed here:

          • https://doc.qt.io/qt-6/qaction.html#signals

          and triggered(bool checkstate) is explained here:

          • https://doc.qt.io/qt-6/qaction.html#triggered
          Axel SpoerlA Offline
          Axel SpoerlA Offline
          Axel Spoerl
          Moderators
          wrote on last edited by Axel Spoerl
          #4

          Like @Pl45m4 mentioned, I generally recommend to use this syntax, instead of the SIGNAL / SLOT marcros:

          connect(subAction[index], &QAction::triggered, this, &WHATEVER_CLASS_YOU_ARE_IN::testSlot);
          

          The difference is: The latter uses pointer to member functions ("PMF"). It gives you a compile time error, if something doesn't work. It's much faster during runtime.

          The old macro based connect syntax parses strings in meta objects, to find the right function pointer to connect to. It requires the signature of the functions to be explicitly stated. The reason why your second connect doesn't work is that the QAction::triggered()signal has a bool argument. You would have to specify SIGNAL(triggered(bool)), as well as the correct signature of your test slot.
          All of that isn't needed, if you use the PMF syntax.

          For the records: PMF syntax has some limitations with regard to default arguments, but that's corner cases. The connect happens exactly at the same time. The automatic disconnect happens later: Macro-based connects are disconnected, when the meta object goes out of scope. If you have a class inheriting from QObject, the disconnect happens when the inheriting class is deleted. At that time, the class is only a QObject. PMF connections stay alive and point to a stale object. That can potentially cause crashes, when a signal gets emitted to a class in destruction. PMF connections need to be explicitly disconnected in the d'tor of the inheriting class in such cases.

          Software Engineer
          The Qt Company, Oslo

          A 1 Reply Last reply
          3
          • A Anonymous_Banned275

            Could some kind person - without need to know what I am doing or without reference to RTFM kindly explain the difference between "connect"
            ?

            { //process
                            for (int index = 0; index < list_hcitool.size(); ++index)
                            {
                                text = "Add subsubmenu";
                                subtempmenu = new QMenu();
                                subtempmenu->setTitle(list_hcitool[index] + " #" + QString::number(index));
                                subMenu[index]  = tempmenu; //m_ui->menuWindow_cpntrol;
                                subAction[index] = subMenu[index]->addMenu(subtempmenu);
                                subAction[index]->setVisible(true);
                                subAction[index]->setCheckable(true);
            subAction[index]->triggered(true);
                                qDebug() << list_hcitool[index];
            **THIS connect runs testSlot
                                // connect here ??
            //                    connect(subAction[index],
            //                           SIGNAL(hovered()),
            //                           this,SLOT(testSlot()));**
            
            
            **THIS ONE DOES NOT 
                                connect(
                                        subAction[index],
                                        SIGNAL(triggered()),
                                        this,
                                        SLOT(testSlot()));
            
            ```**
            
            
            
            My guess - the SIGNAL "triggered"  code is missing something.
            
            
            Thanks for your help.
            J.HilkJ Offline
            J.HilkJ Offline
            J.Hilk
            Moderators
            wrote on last edited by
            #5
            This post is deleted!
            1 Reply Last reply
            0
            • Axel SpoerlA Axel Spoerl

              Like @Pl45m4 mentioned, I generally recommend to use this syntax, instead of the SIGNAL / SLOT marcros:

              connect(subAction[index], &QAction::triggered, this, &WHATEVER_CLASS_YOU_ARE_IN::testSlot);
              

              The difference is: The latter uses pointer to member functions ("PMF"). It gives you a compile time error, if something doesn't work. It's much faster during runtime.

              The old macro based connect syntax parses strings in meta objects, to find the right function pointer to connect to. It requires the signature of the functions to be explicitly stated. The reason why your second connect doesn't work is that the QAction::triggered()signal has a bool argument. You would have to specify SIGNAL(triggered(bool)), as well as the correct signature of your test slot.
              All of that isn't needed, if you use the PMF syntax.

              For the records: PMF syntax has some limitations with regard to default arguments, but that's corner cases. The connect happens exactly at the same time. The automatic disconnect happens later: Macro-based connects are disconnected, when the meta object goes out of scope. If you have a class inheriting from QObject, the disconnect happens when the inheriting class is deleted. At that time, the class is only a QObject. PMF connections stay alive and point to a stale object. That can potentially cause crashes, when a signal gets emitted to a class in destruction. PMF connections need to be explicitly disconnected in the d'tor of the inheriting class in such cases.

              A Offline
              A Offline
              Anonymous_Banned275
              wrote on last edited by
              #6

              @Axel-Spoer

              I have made some changes
              and getting messages in run.

              l ```
              { //process
              for (int index = 0; index < list_hcitool.size(); ++index)
              {
              text = "Add subsubmenu";
              subtempmenu = new QMenu();
              subtempmenu->setTitle(list_hcitool[index] + " #" + QString::number(index));
              subMenu[index] = tempmenu; //m_ui->menuWindow_cpntrol;
              subAction[index] = subMenu[index]->addMenu(subtempmenu);
              subAction[index]->setVisible(true);
              subAction[index]->setCheckable(true);
              //subAction[index]->setChecked(true);
              subAction[index]->triggered(true);
              qDebug() << list_hcitool[index];

                              // connect here ??
                              connect (
                                          subMenu[index],
                                          SIGNAL(checked(true)),
                                          this,
                                          SLOT(testSlot(true)));
                              connect (
                                          subMenu[index],
                                          SIGNAL(triggered(true)),
                                          this,
                                          SLOT(testSlot(true)));
              
              Run time messages:
              
              **( only the highlighted shoud be analysed it is a loop)**   
              
                "
              QObject::connect: No such signal **QMenu::checked(true) in mainwindow_Bluetooth.cpp:1590
              QObject::connect:  (receiver name: 'MainWindow_Bluetooth')
              QObject::connect: No such signal QMenu::triggered(true) in mainwindow_Bluetooth.cpp:1595
              QObject::connect:  (receiver name: 'MainWindow_Bluetooth')
              "command   hcitool   dev "**
              QObject::connect: No such signal QMenu::checked(true) in mainwindow_Bluetooth.cpp:1590
              QObject::connect:  (receiver name: 'MainWindow_Bluetooth')
              QObject::connect: No such signal QMenu::triggered(true) in mainwindow_Bluetooth.cpp:1595
              QObject::connect:  (receiver name: 'MainWindow_Bluetooth')
              "command   hcitool   scan "
              QObject::connect: No such signal QMenu::checked(true) in mainwindow_Bluetooth.cpp:1590
              QObject::connect:  (receiver name: 'MainWindow_Bluetooth')
              QObject::connect: No such signal QMenu::triggered(true) in mainwindow_Bluetooth.cpp:1595
              QObject::connect:  (receiver name: 'MainWindow_Bluetooth')
              "command   hcitool   inq  "
              QObject::connect: No such signal QMenu::checked(true) in mainwindow_Bluetooth.cpp:1590
              QObject::connect:  (receiver name: 'MainWindow_Bluetooth')
              QObject::connect: No such signal QMenu::triggered(true) in mainwindow_Bluetooth.cpp:1595
              QObject::connect:  (receiver name: 'MainWindow_Bluetooth')ud nr analused, it is in loop..)
              
              
              
              

              ol "
              QObject::connect: No such signal QMenu::checked(true) in mainwindow_Bluetooth.cpp:1590
              QObject::connect: (receiver name: 'MainWindow_Bluetooth')
              QObject::connect: No such signal QMenu::triggered(true) in mainwindow_Bluetooth.cpp:1595
              QObject::connect: (receiver name: 'MainWindow_Bluetooth')
              "command hcitool dev "

              QObject::connect: No such signal QMenu::checked(true) in mainwindow_Bluetooth.cpp:1590
              QObject::connect: (receiver name: 'MainWindow_Bluetooth')
              QObject::connect: No such signal QMenu::triggered(true) in mainwindow_Bluetooth.cpp:1595
              QObject::connect: (receiver name: 'MainWindow_Bluetooth')
              "command hcitool scan "
              QObject::connect: No such signal QMenu::checked(true) in mainwindow_Bluetooth.cpp:1590
              QObject::connect: (receiver name: 'MainWindow_Bluetooth')
              QObject::connect: No such signal QMenu::triggered(true) in mainwindow_Bluetooth.cpp:1595
              QObject::connect: (receiver name: 'MainWindow_Bluetooth')
              "command hcitool inq "
              QObject::connect: No such signal QMenu::checked(true) in mainwindow_Bluetooth.cpp:1590
              QObject::connect: (receiver name: 'MainWindow_Bluetooth')
              QObject::connect: No such signal QMenu::triggered(true) in mainwindow_Bluetooth.cpp:1595
              QObject::connect: (receiver name: 'MainWindow_Bluetooth')

              JonBJ 1 Reply Last reply
              0
              • A Anonymous_Banned275

                @Axel-Spoer

                I have made some changes
                and getting messages in run.

                l ```
                { //process
                for (int index = 0; index < list_hcitool.size(); ++index)
                {
                text = "Add subsubmenu";
                subtempmenu = new QMenu();
                subtempmenu->setTitle(list_hcitool[index] + " #" + QString::number(index));
                subMenu[index] = tempmenu; //m_ui->menuWindow_cpntrol;
                subAction[index] = subMenu[index]->addMenu(subtempmenu);
                subAction[index]->setVisible(true);
                subAction[index]->setCheckable(true);
                //subAction[index]->setChecked(true);
                subAction[index]->triggered(true);
                qDebug() << list_hcitool[index];

                                // connect here ??
                                connect (
                                            subMenu[index],
                                            SIGNAL(checked(true)),
                                            this,
                                            SLOT(testSlot(true)));
                                connect (
                                            subMenu[index],
                                            SIGNAL(triggered(true)),
                                            this,
                                            SLOT(testSlot(true)));
                
                Run time messages:
                
                **( only the highlighted shoud be analysed it is a loop)**   
                
                  "
                QObject::connect: No such signal **QMenu::checked(true) in mainwindow_Bluetooth.cpp:1590
                QObject::connect:  (receiver name: 'MainWindow_Bluetooth')
                QObject::connect: No such signal QMenu::triggered(true) in mainwindow_Bluetooth.cpp:1595
                QObject::connect:  (receiver name: 'MainWindow_Bluetooth')
                "command   hcitool   dev "**
                QObject::connect: No such signal QMenu::checked(true) in mainwindow_Bluetooth.cpp:1590
                QObject::connect:  (receiver name: 'MainWindow_Bluetooth')
                QObject::connect: No such signal QMenu::triggered(true) in mainwindow_Bluetooth.cpp:1595
                QObject::connect:  (receiver name: 'MainWindow_Bluetooth')
                "command   hcitool   scan "
                QObject::connect: No such signal QMenu::checked(true) in mainwindow_Bluetooth.cpp:1590
                QObject::connect:  (receiver name: 'MainWindow_Bluetooth')
                QObject::connect: No such signal QMenu::triggered(true) in mainwindow_Bluetooth.cpp:1595
                QObject::connect:  (receiver name: 'MainWindow_Bluetooth')
                "command   hcitool   inq  "
                QObject::connect: No such signal QMenu::checked(true) in mainwindow_Bluetooth.cpp:1590
                QObject::connect:  (receiver name: 'MainWindow_Bluetooth')
                QObject::connect: No such signal QMenu::triggered(true) in mainwindow_Bluetooth.cpp:1595
                QObject::connect:  (receiver name: 'MainWindow_Bluetooth')ud nr analused, it is in loop..)
                
                
                
                

                ol "
                QObject::connect: No such signal QMenu::checked(true) in mainwindow_Bluetooth.cpp:1590
                QObject::connect: (receiver name: 'MainWindow_Bluetooth')
                QObject::connect: No such signal QMenu::triggered(true) in mainwindow_Bluetooth.cpp:1595
                QObject::connect: (receiver name: 'MainWindow_Bluetooth')
                "command hcitool dev "

                QObject::connect: No such signal QMenu::checked(true) in mainwindow_Bluetooth.cpp:1590
                QObject::connect: (receiver name: 'MainWindow_Bluetooth')
                QObject::connect: No such signal QMenu::triggered(true) in mainwindow_Bluetooth.cpp:1595
                QObject::connect: (receiver name: 'MainWindow_Bluetooth')
                "command hcitool scan "
                QObject::connect: No such signal QMenu::checked(true) in mainwindow_Bluetooth.cpp:1590
                QObject::connect: (receiver name: 'MainWindow_Bluetooth')
                QObject::connect: No such signal QMenu::triggered(true) in mainwindow_Bluetooth.cpp:1595
                QObject::connect: (receiver name: 'MainWindow_Bluetooth')
                "command hcitool inq "
                QObject::connect: No such signal QMenu::checked(true) in mainwindow_Bluetooth.cpp:1590
                QObject::connect: (receiver name: 'MainWindow_Bluetooth')
                QObject::connect: No such signal QMenu::triggered(true) in mainwindow_Bluetooth.cpp:1595
                QObject::connect: (receiver name: 'MainWindow_Bluetooth')

                JonBJ Offline
                JonBJ Offline
                JonB
                wrote on last edited by JonB
                #7

                @AnneRanch
                As said before, if you never used SIGNAL/SLOT() macros you would never get such errors.

                However, given that you have, you can never specify a value as a parameter to either the signal or slot as you have with the true in SIGNAL(checked(true)) or in SLOT(testSlot(true)). You must always a specify the type of the value, not its value, so e.g. here SIGNAL(checked(bool)), and the same for the other three occurrences.

                However, signal QMenu::triggered(QAction *action) as you can see does not send any boolean, it sends a QAction *. And there is no QMenu::checked signal at all. OTOH, void QAction::triggered(bool checked = false) does exist, and sends a bool, so maybe you mean to be connecting signals from a QAction not a QMenu? I still do not see any QAction::checked signal though, but there is a QAction::toggled(bool checked).

                And to be clear: triggered refers to clicking the menu action (i.e. do whatever it is supposed to do when clicked) while toggled refers to changing the state of a checkbox you have asked the action to show (i.e. clicking the checkbox of the action rather than on the action text).

                @Axel-Spoerl showed a suitable connect() earlier:

                connect(subAction[index], &QAction::triggered, this, &WHATEVER_CLASS_YOU_ARE_IN::testSlot);
                

                As you can see, it is the QAction signals which we connect, not QMenu ones.

                Pl45m4P 1 Reply Last reply
                3
                • JonBJ JonB

                  @AnneRanch
                  As said before, if you never used SIGNAL/SLOT() macros you would never get such errors.

                  However, given that you have, you can never specify a value as a parameter to either the signal or slot as you have with the true in SIGNAL(checked(true)) or in SLOT(testSlot(true)). You must always a specify the type of the value, not its value, so e.g. here SIGNAL(checked(bool)), and the same for the other three occurrences.

                  However, signal QMenu::triggered(QAction *action) as you can see does not send any boolean, it sends a QAction *. And there is no QMenu::checked signal at all. OTOH, void QAction::triggered(bool checked = false) does exist, and sends a bool, so maybe you mean to be connecting signals from a QAction not a QMenu? I still do not see any QAction::checked signal though, but there is a QAction::toggled(bool checked).

                  And to be clear: triggered refers to clicking the menu action (i.e. do whatever it is supposed to do when clicked) while toggled refers to changing the state of a checkbox you have asked the action to show (i.e. clicking the checkbox of the action rather than on the action text).

                  @Axel-Spoerl showed a suitable connect() earlier:

                  connect(subAction[index], &QAction::triggered, this, &WHATEVER_CLASS_YOU_ARE_IN::testSlot);
                  

                  As you can see, it is the QAction signals which we connect, not QMenu ones.

                  Pl45m4P Offline
                  Pl45m4P Offline
                  Pl45m4
                  wrote on last edited by
                  #8

                  @AnneRanch

                  @JonB said in How to "trigger" from check bpx...?:

                  However, signal QMenu::triggered(QAction *action) as you can see does not send any boolean, it sends a QAction *. And there is no QMenu::checked signal at all. OTOH, void QAction::triggered(bool checked = false) does exist, and sends a bool, so maybe you mean to be connecting signals from a QAction not a QMenu? I still do not see any QAction::checked signal though, but there is a QAction::toggled(bool checked).

                  That's why I wrote

                  @Pl45m4 said in How to "trigger" from check bpx...?:

                  connect(subAction[index], SIGNAL(triggered(bool))), this, SLOT(testSlot(bool));
                  // OR
                  connect(subAction[index], &QAction::triggered, this, &WHATEVER_CLASS_YOU_ARE_IN::testSlot);

                  but I don't know why I'm doing this... You recommend something, the advice gets ignored, bullsh*t happens with tons of errors (of course) and then getting asked what's wrong again
                  (╯°□°)╯︵ ┻━┻

                  I mean, you are not a new user anymore, but despite the fact that you don't have any programming "background", you should at least know how a (more or less) simple connection works.
                  We are going round in circles, since years.
                  Aren't you also eager to learn something and to finish your program?!
                  A lot of us are really patient with you and try the best they can to explain and "teach"... but it's pretty frustrating to deal with the same stuff over and over again. It's not wrong to ask these questions but...sometimes I just can't...
                  (often the solution is right there or just one click on a link / one documentation page away... If we refer, it's "RTFM"... which is not a bad thing)


                  If debugging is the process of removing software bugs, then programming must be the process of putting them in.

                  ~E. W. Dijkstra

                  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