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. Why
Qt 6.11 is out! See what's new in the release blog

Why

Scheduled Pinned Locked Moved Unsolved General and Desktop
6 Posts 3 Posters 983 Views 1 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.
  • E Offline
    E Offline
    ExactPlace441
    wrote on last edited by
    #1

    Hello. I am writing code for a QT Widget application.

    I made buttons in the past and used slots to enable actions for them when the user uses them. However, I changed the name of one of the buttons from action_import to menuBar_import after doing the plug. Because of this, I now have two cases, where one applies to the previous name of a widget that does not exist.

    How can I fix this? I receive an error upon trying to run my code since case 0 is bad now. Now, I can remove case 0 to get my code to work, but I do not want to do this each time.

    Error:
    b431eecb-2e3f-49f7-ac3f-6cd37c19389e-image.png

    void MainWindow::qt_static_metacall(QObject *_o, QMetaObject::Call _c, int _id, void **_a)
    {
        if (_c == QMetaObject::InvokeMetaMethod) {
            auto *_t = static_cast<MainWindow *>(_o);
            (void)_t;
            switch (_id) {
            case 0: _t->on_actionImport_triggered(); break;
            case 1: _t->on_menuBar_import_triggered(); break;
            case 2: _t->on_menuBar_export_triggered(); break;
            case 3: _t->on_button_quizInfo_clicked(); break;
            default: ;
            }
        }
        (void)_a;
    }
    

    Thank you!

    1 Reply Last reply
    0
    • E Offline
      E Offline
      ExactPlace441
      wrote on last edited by
      #2

      Edit: Pardon the poor title. I forgot to finish it. I will repost with a better title.

      1 Reply Last reply
      1
      • SGaistS Offline
        SGaistS Offline
        SGaist
        Lifetime Qt Champion
        wrote on last edited by SGaist
        #3

        Hi and welcome to devnet,

        Just edit the title, no need to repost.

        It seems you are using the auto connect feature.

        It would be simpler to manually do the connections yourself. This will also save you time when renaming widgets.

        Interested in AI ? www.idiap.ch
        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

        E 1 Reply Last reply
        1
        • SGaistS SGaist

          Hi and welcome to devnet,

          Just edit the title, no need to repost.

          It seems you are using the auto connect feature.

          It would be simpler to manually do the connections yourself. This will also save you time when renaming widgets.

          E Offline
          E Offline
          ExactPlace441
          wrote on last edited by
          #4

          @SGaist

          Thank you for helping me out.

          Would it be alright for you to point me in the direction of disabling auto-connect? I removed the function from the mainwindow.cpp altogether, but it still shows up.

          Furthermore, I added a new button slot by right clicking a new button, then clicking "Go to slot", then adding an action upon click. After removing the resulting code from the mainwindow.cpp, I still receive an error for it.

          1 Reply Last reply
          0
          • SGaistS Offline
            SGaistS Offline
            SGaist
            Lifetime Qt Champion
            wrote on last edited by
            #5

            To stop using auto connection, do not use on_XXX_signalName.

            Create slots with meaningful name in the code and then connect them at the end of your constructor.

            Interested in AI ? www.idiap.ch
            Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

            1 Reply Last reply
            1
            • C Offline
              C Offline
              ChrisW67
              wrote on last edited by ChrisW67
              #6

              Do a clean build of your project so that moc runs and moc_mainwindow.cpp is regenerated to match your actual MainWindow declarations in mainwindow.h (which should be on_menuBar_import_triggered())

              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