Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Special Interest Groups
  3. C++ Gurus
  4. How to get rid of changed code lingering in the moc?
Forum Updated to NodeBB v4.3 + New Features

How to get rid of changed code lingering in the moc?

Scheduled Pinned Locked Moved Solved C++ Gurus
8 Posts 4 Posters 4.3k 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.
  • ? Offline
    ? Offline
    A Former User
    wrote on last edited by A Former User
    #1

    In my main menu, I had an action set up and its accompanying code. Then I decided to change the action name on the menu to something else. I did that and took the code from the first, no-longer-needed action and gave it to the new action. Now I get this each time I run it:

    QMetaObject::connectSlotsByName: No matching signal for on_actionA_lter_triggered()
    

    I've tried to "Clean" the build, thinking that would cure the moc's ailment, but no dice. So what can I do to fix this? This is the ONE thing about Qt that drives me crazy.

    aha_1980A 1 Reply Last reply
    0
    • ? A Former User

      In my main menu, I had an action set up and its accompanying code. Then I decided to change the action name on the menu to something else. I did that and took the code from the first, no-longer-needed action and gave it to the new action. Now I get this each time I run it:

      QMetaObject::connectSlotsByName: No matching signal for on_actionA_lter_triggered()
      

      I've tried to "Clean" the build, thinking that would cure the moc's ailment, but no dice. So what can I do to fix this? This is the ONE thing about Qt that drives me crazy.

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

      hi @landslyde

      you most likely still have the slot function in you code, but the signal no longer exists.

      that's what the connect error message is going to tell you.

      Qt has to stay free or it will die.

      1 Reply Last reply
      2
      • ? Offline
        ? Offline
        A Former User
        wrote on last edited by
        #3

        I've tried taking it out. That only throws an error in the moc. I'll post this.

        Code commented out:

        //void MainWindow::on_actionA_lter_triggered()
        //{
        
        //}
        

        Error thrown in the moc:

        /home/slyde/Desktop/Qt/build-Qt_Stacked_Widget-Desktop_Qt_5_11_0_GCC_64bit-Debug/moc_mainwindow.cpp:100: error: undefined reference to `MainWindow::on_actionA_lter_triggered()'
        

        The error code:

        void MainWindow::qt_static_metacall(QObject *_o, QMetaObject::Call _c, int _id, void **_a)
        {
            if (_c == QMetaObject::InvokeMetaMethod) {
                MainWindow *_t = static_cast<MainWindow *>(_o);
                Q_UNUSED(_t)
                switch (_id) {
                case 0: _t->on_actionE_xit_triggered(); break;
                case 1: _t->on_actionA_lter_triggered(); break;  // throws error here
                case 2: _t->on_action_Add_triggered(); break;
                case 3: _t->on_action_Delete_triggered(); break;
                case 4: _t->on_action_View_triggered(); break;
                case 5: _t->on_action_Search_triggered(); break;
                case 6: _t->on_btnCancel_add_recipe_clicked(); break;
                case 7: _t->on_action_Edit_triggered(); break;
                default: ;
                }
            }
            Q_UNUSED(_a);
        }
        

        I can comment out that line "case 1:" and I go back to getting a warning. There has to be a way for this to be cleaned out of the code. I know I'm not the first person that's ever changed his mind on the name of something.

        1 Reply Last reply
        1
        • ? Offline
          ? Offline
          A Former User
          wrote on last edited by A Former User
          #4

          Fixed it. Thank you, aha_1980.

          aha_1980A 1 Reply Last reply
          2
          • ? A Former User

            Fixed it. Thank you, aha_1980.

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

            Hi @landslyde,

            glad you figured it out.

            Running Qmake most often helps, in very rare cases you need to delete your build folder to get the error away.

            Qt has to stay free or it will die.

            1 Reply Last reply
            1
            • ? Offline
              ? Offline
              A Former User
              wrote on last edited by A Former User
              #6

              Actually, while I'd deleted the action code from mainwindow.cpp, I hadn't deleted its prototype in mainwindow.h. That's what the compiler was complaining about. So I deleted it in the .h and then ran Build -> Clean All. Doing that removed the reference to the deleted action in the moc file. Problem solved. Thanks again for your help.

              1 Reply Last reply
              1
              • F Offline
                F Offline
                FeiMingDi
                wrote on last edited by
                #7

                Same thing here. Once you changed the object name for a button (or other widget), you need to comment out the deprecated slot function in the header file of the class that holds the ui form.
                The moc_mainwindow.cpp in the build folder, however, will be updated by itself, so no need to worry about that.

                1 Reply Last reply
                0
                • A Offline
                  A Offline
                  Anonymous_Banned275
                  wrote on last edited by
                  #8

                  I have managed to do same few times.
                  I do not get why rudimentary error such "missing reference" gets reported by "moc" and really does not point to the real source.
                  To me "moc" errors are above "compiler error" and before "run time error".
                  I am still getting few - " moc' file removed from disk - what do you want to do next?
                  It would be nice for some learned person to explain how "moc" errors help in debugging - in general terms.
                  And I do apologize for "me too" hijacking post.
                  Cheers

                  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