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. Deleting sections from a moc file
Qt 6.11 is out! See what's new in the release blog

Deleting sections from a moc file

Scheduled Pinned Locked Moved Unsolved General and Desktop
moc
7 Posts 3 Posters 3.6k 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.
  • G Offline
    G Offline
    gabor53
    wrote on last edited by
    #1

    Hi,
    I have QDialog called review (review.h, review.cpp and review.ui).
    When I run the program I get the following error message:

    C:\Programming\Projects\build-Folkfriends_1-Desktop_Qt_5_6_1_MinGW_32bit2-Debug\debug\moc_review.cpp:70: error: undefined reference to `Review::on_pushButton_Submit_clicked()'

    moc-review.cpp has the following code at line 70:

    void Review::qt_static_metacall(QObject *_o, QMetaObject::Call _c, int _id, void **_a)
    {
        if (_c == QMetaObject::InvokeMetaMethod) {
            Review *_t = static_cast<Review *>(_o);
            Q_UNUSED(_t)
            switch (_id) {
            case 0: _t->on_pushButton_Submit_clicked(); break;
            default: ;
            }
        }
        Q_UNUSED(_a);
    }
    

    where line 70 is the line starts with case 0.
    the pushButton it refers to is non existent any more but this line clearly refers to it. How can I eliminate this reference? If I just simply delete it it causes a SIGSEGV error.
    Thank you for your help.

    1 Reply Last reply
    0
    • mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @gabor53 said:

      Review::on_pushButton_Submit_clicked()'

      hi
      Delete the moc file
      Remove the slot from
      Review.h
      Clean all, rebuild all, maybe run qmake
      and it should be gone.

      G 1 Reply Last reply
      2
      • mrjjM mrjj

        @gabor53 said:

        Review::on_pushButton_Submit_clicked()'

        hi
        Delete the moc file
        Remove the slot from
        Review.h
        Clean all, rebuild all, maybe run qmake
        and it should be gone.

        G Offline
        G Offline
        gabor53
        wrote on last edited by
        #3

        @mrjj
        I did as you told. The original problem is gone. Instead I get a few dozen new error messages. At additem.h I have this code:

        
        namespace Ui {
        class Additem;
        }
        class Additem : public QDialog
        {
            Q_OBJECT
        
        public:
            explicit Additem(QWidget *parent = 0);
            ~Additem();
        
        

        For the class Additem row it gives the following error message:
        C:\Programming\Projects\Folkfriends_1\additem.cpp:6: error: invalid use of incomplete type 'class Ui::Additem'
        ui(new Ui::Additem)
        ^
        I assume all the other error messages come from the fact that the class definition is somehow incorrect. What is wrong with it? It used to work...

        jsulmJ 1 Reply Last reply
        0
        • G gabor53

          @mrjj
          I did as you told. The original problem is gone. Instead I get a few dozen new error messages. At additem.h I have this code:

          
          namespace Ui {
          class Additem;
          }
          class Additem : public QDialog
          {
              Q_OBJECT
          
          public:
              explicit Additem(QWidget *parent = 0);
              ~Additem();
          
          

          For the class Additem row it gives the following error message:
          C:\Programming\Projects\Folkfriends_1\additem.cpp:6: error: invalid use of incomplete type 'class Ui::Additem'
          ui(new Ui::Additem)
          ^
          I assume all the other error messages come from the fact that the class definition is somehow incorrect. What is wrong with it? It used to work...

          jsulmJ Offline
          jsulmJ Offline
          jsulm
          Lifetime Qt Champion
          wrote on last edited by jsulm
          #4

          @gabor53 Looks like moc is not executed for additem. Did you rerun qmake and rebuild? Were ui_additem.h/cpp generated? Did you include ui_additem.h in additem.cpp?

          https://forum.qt.io/topic/113070/qt-code-of-conduct

          G 1 Reply Last reply
          1
          • jsulmJ jsulm

            @gabor53 Looks like moc is not executed for additem. Did you rerun qmake and rebuild? Were ui_additem.h/cpp generated? Did you include ui_additem.h in additem.cpp?

            G Offline
            G Offline
            gabor53
            wrote on last edited by
            #5

            @jsulm I checked those files and the ui files were missing from the cpps. After fixing I get a new problem. In moc_mainwindow.cpp there is a line that crashes the program:

            const QMetaObject *MainWindow::metaObject() const
            {
                return QObject::d_ptr->metaObject ? QObject::d_ptr->dynamicMetaObject() : &staticMetaObject;
            }
            

            According to the debugger the line starting with return crashes the program. What can I do with it? (I ran clean and rebuild and qmake already.) I also noticed that I have Qt 5.7 but it runs with the Desktop Qt 5.6.1 MinGW 32bit. Can this be a problem?

            jsulmJ 1 Reply Last reply
            0
            • G gabor53

              @jsulm I checked those files and the ui files were missing from the cpps. After fixing I get a new problem. In moc_mainwindow.cpp there is a line that crashes the program:

              const QMetaObject *MainWindow::metaObject() const
              {
                  return QObject::d_ptr->metaObject ? QObject::d_ptr->dynamicMetaObject() : &staticMetaObject;
              }
              

              According to the debugger the line starting with return crashes the program. What can I do with it? (I ran clean and rebuild and qmake already.) I also noticed that I have Qt 5.7 but it runs with the Desktop Qt 5.6.1 MinGW 32bit. Can this be a problem?

              jsulmJ Offline
              jsulmJ Offline
              jsulm
              Lifetime Qt Champion
              wrote on last edited by
              #6

              @gabor53 Do you call base class constructor in MainWindow constructor?
              Can you show MainWindow?
              If you build your application with Qt 5.7 then you should execute it with 5.7

              https://forum.qt.io/topic/113070/qt-code-of-conduct

              G 1 Reply Last reply
              0
              • jsulmJ jsulm

                @gabor53 Do you call base class constructor in MainWindow constructor?
                Can you show MainWindow?
                If you build your application with Qt 5.7 then you should execute it with 5.7

                G Offline
                G Offline
                gabor53
                wrote on last edited by
                #7

                @jsulm Here is the code:

                mainwindow.h
                mainwindow.cpp
                moc_mainwindow.cpp

                Thank you for your help.

                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