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. undefined reference to `Config::SingleLinkedList::staticMetaObject' and `vtable for Config::SingleLinkedList'

undefined reference to `Config::SingleLinkedList::staticMetaObject' and `vtable for Config::SingleLinkedList'

Scheduled Pinned Locked Moved Solved General and Desktop
14 Posts 6 Posters 3.5k 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.
  • LimerL Offline
    LimerL Offline
    Limer
    wrote on last edited by
    #1

    class ConfigBase : public QWidget, it has slots and signals, so Q_OBJECT is set in the code.

    Now, class SingleLinkedList : public ConfigBase , it also has its own slots and signals, so Q_OBJECT is also set in the code. But i come across one problem.

    error: undefined reference to `Config::SingleLinkedList::staticMetaObject'

    error: undefined reference to `vtable for Config::SingleLinkedList'

    collect2.exe:-1: error: error: ld returned 1 exit status

    I googled many, but no use.

    If you want all the project(it is a little project, but is not convenient to public), leave your email !

    aha_1980A joeQJ 2 Replies Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      Did you add/remove the Q_OBJECT macro at some point ? If so you should re-run qmake or do a full rebuild.

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

      LimerL 1 Reply Last reply
      1
      • SGaistS SGaist

        Hi,

        Did you add/remove the Q_OBJECT macro at some point ? If so you should re-run qmake or do a full rebuild.

        LimerL Offline
        LimerL Offline
        Limer
        wrote on last edited by
        #3

        @SGaist

        I tried, no use.

        1 Reply Last reply
        0
        • LimerL Limer

          class ConfigBase : public QWidget, it has slots and signals, so Q_OBJECT is set in the code.

          Now, class SingleLinkedList : public ConfigBase , it also has its own slots and signals, so Q_OBJECT is also set in the code. But i come across one problem.

          error: undefined reference to `Config::SingleLinkedList::staticMetaObject'

          error: undefined reference to `vtable for Config::SingleLinkedList'

          collect2.exe:-1: error: error: ld returned 1 exit status

          I googled many, but no use.

          If you want all the project(it is a little project, but is not convenient to public), leave your email !

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

          @Limer said in undefined reference to `Config::SingleLinkedList::staticMetaObject' and `vtable for Config::SingleLinkedList':

          class ConfigBase : public QWidget, it has slots and signals, so Q_OBJECT is set in the code.

          Hello, is your class defined in a header or in a cpp file?

          If it's in a header file, try deleting the whole build folder (make sure there are no Makefiles left, neither in the source nor in the build folder).

          If the definition is in a cpp file, then you will have to include the generated .moc file your own by apppending something like #include "singlelinkedlist.moc" at the end of your cpp file.

          Qt has to stay free or it will die.

          LimerL 1 Reply Last reply
          2
          • aha_1980A aha_1980

            @Limer said in undefined reference to `Config::SingleLinkedList::staticMetaObject' and `vtable for Config::SingleLinkedList':

            class ConfigBase : public QWidget, it has slots and signals, so Q_OBJECT is set in the code.

            Hello, is your class defined in a header or in a cpp file?

            If it's in a header file, try deleting the whole build folder (make sure there are no Makefiles left, neither in the source nor in the build folder).

            If the definition is in a cpp file, then you will have to include the generated .moc file your own by apppending something like #include "singlelinkedlist.moc" at the end of your cpp file.

            LimerL Offline
            LimerL Offline
            Limer
            wrote on last edited by
            #5

            @aha_1980

            In a heaer file. I tried, but it doesn`t work.

            1 Reply Last reply
            0
            • LimerL Limer

              class ConfigBase : public QWidget, it has slots and signals, so Q_OBJECT is set in the code.

              Now, class SingleLinkedList : public ConfigBase , it also has its own slots and signals, so Q_OBJECT is also set in the code. But i come across one problem.

              error: undefined reference to `Config::SingleLinkedList::staticMetaObject'

              error: undefined reference to `vtable for Config::SingleLinkedList'

              collect2.exe:-1: error: error: ld returned 1 exit status

              I googled many, but no use.

              If you want all the project(it is a little project, but is not convenient to public), leave your email !

              joeQJ Offline
              joeQJ Offline
              joeQ
              wrote on last edited by
              #6

              @Limer Hi, friend.

              1. Dot forget to add Q_OBJECT in head of class.
              2. run qmake again.

              If not Ok, you could show some code in your post.

              Just do it!

              LimerL 1 Reply Last reply
              0
              • joeQJ joeQ

                @Limer Hi, friend.

                1. Dot forget to add Q_OBJECT in head of class.
                2. run qmake again.

                If not Ok, you could show some code in your post.

                LimerL Offline
                LimerL Offline
                Limer
                wrote on last edited by
                #7

                @joeQ

                #ifndef CONFIG_BASE_H
                #define CONFIG_BASE_H
                
                #include <QPushButton>
                #include <QSlider>
                #include <QGridLayout>
                #include <QGroupBox>
                
                #define CONFIG_NAMESPACE_START namespace Config {
                #define CONFIG_NAMESPACE_END   }
                
                class ConfigBase : public QWidget
                {
                    Q_OBJECT
                
                public:
                    explicit ConfigBase(QWidget *parent = 0) : QWidget(parent)
                    {
                        groupBox1 = new QGroupBox(tr("Speed Control"));
                        speedSlider = new QSlider(Qt::Horizontal, groupBox1);
                        speedSlider->setMinimum(0);
                        speedSlider->setMaximum(300);
                        speedSlider->setValue(150);
                        sliderLayout = new QVBoxLayout(groupBox1);
                        sliderLayout->addWidget(speedSlider);
                
                        groupBox2 = new QGroupBox(tr("Start && Pause"));
                        startPushButton = new QPushButton(tr("Start"));
                        pausePushButton = new QPushButton(tr("Pause"));
                        resetPushButton = new QPushButton(tr("Reset"));
                        startPushButton->setEnabled(true);
                        pausePushButton->setEnabled(false);
                        resetPushButton->setEnabled(false);
                        pushButtonLayout = new QGridLayout(groupBox2);
                        pushButtonLayout->addWidget(startPushButton, 0, 0, 1, 1);
                        pushButtonLayout->addWidget(pausePushButton, 0, 1, 1, 1);
                        pushButtonLayout->addWidget(resetPushButton, 1, 0, 1, 1);
                
                        connect(startPushButton, SIGNAL(clicked(bool)), SLOT(start()));
                        connect(pausePushButton, SIGNAL(clicked(bool)), SLOT(pause()));
                        connect(resetPushButton, SIGNAL(clicked(bool)), SLOT(reset()));
                    }
                
                    ~ConfigBase()
                    {}
                
                public slots:
                    void start()
                    {
                        startPushButton->setEnabled(false);
                        pausePushButton->setEnabled(true);
                        emit comboBoxEnabled(false);
                    }
                
                    void pause()
                    {
                        if (pausePushButton->text() == QString(QObject::tr("Pause")))
                        {
                            pausePushButton->setText(QObject::tr("Continue"));
                            resetPushButton->setEnabled(true);
                            emit comboBoxEnabled(true);
                        }
                        else
                        {
                            pausePushButton->setText(QObject::tr("Pause"));
                            resetPushButton->setEnabled(false);
                            emit comboBoxEnabled(false);
                        }
                    }
                
                    void reset()
                    {
                        pausePushButton->setText(QObject::tr("Pause"));
                        startPushButton->setEnabled(true);
                        pausePushButton->setEnabled(false);
                        resetPushButton->setEnabled(false);
                        speedSlider->setValue(150);
                        emit comboBoxEnabled(true);
                    }
                
                signals:
                    void comboBoxEnabled(bool);
                
                public:
                    QPushButton *startPushButton;
                    QPushButton *pausePushButton;
                    QPushButton *resetPushButton;
                    QSlider     *speedSlider;
                
                protected:
                    QGroupBox   *groupBox1;
                    QGroupBox   *groupBox2;
                
                private:
                    QVBoxLayout *sliderLayout;
                    QGridLayout *pushButtonLayout;
                };
                
                #endif // CONFIG_BASE_H
                
                
                #ifndef CONFIG_SINGLE_LINKED_LIST
                #define CONFIG_SINGLE_LINKED_LIST
                
                #include <QCheckBox>
                #include <QSpinBox>
                #include <QTabWidget>
                #include <QTextEdit>
                #include "config_base.h"
                
                CONFIG_NAMESPACE_START
                
                class SingleLinkedList : public ConfigBase
                {
                    Q_OBJECT
                
                public:
                    explicit SingleLinkedList(ConfigBase *parent = 0) : ConfigBase(parent)
                    {
                        delete groupBox1;
                        startPushButton->setEnabled(false);
                
                        insertWidget      = new QWidget;
                        insertPosGroupBox = new QGroupBox(tr("Position"));
                        insertKeyGroupBox = new QGroupBox(tr("Key"));
                        headCheckBox1     = new QCheckBox(tr("head"));
                        tailCheckBox1     = new QCheckBox(tr("tail"));
                        keyTextEdit1      = new QTextEdit;
                        customSpinBox1    = new QSpinBox;
                        keyTextEdit1->setPlaceholderText(tr("key text edit"));
                        customSpinBox1->setRange(2, 10);
                        QHBoxLayout *hBoxLayout1 = new QHBoxLayout(insertPosGroupBox);
                        hBoxLayout1->addWidget(headCheckBox1);
                        hBoxLayout1->addWidget(tailCheckBox1);
                        hBoxLayout1->addWidget(customSpinBox1);
                        QHBoxLayout *hBoxLayout2 = new QHBoxLayout(insertKeyGroupBox);
                        hBoxLayout2->addWidget(keyTextEdit1);
                        QVBoxLayout *vBoxLayout1 = new QVBoxLayout(insertWidget);
                        vBoxLayout1->addWidget(insertPosGroupBox);
                        vBoxLayout1->addWidget(insertKeyGroupBox);
                        vBoxLayout1->setSpacing(20);
                
                        findWidget       = new QWidget;
                        findKeyGroupBox  = new QGroupBox(tr("Key"));
                        keyTextEdit2     = new QTextEdit;
                        keyTextEdit2->setPlaceholderText(tr("key text edit"));
                        QHBoxLayout *hBoxLayout3 = new QHBoxLayout(findKeyGroupBox);
                        hBoxLayout3->addWidget(keyTextEdit2);
                        QVBoxLayout *vBoxLayout2 = new QVBoxLayout(findWidget);
                        vBoxLayout2->addWidget(findKeyGroupBox);
                
                        removeWidget      = new QWidget;
                        removePosGroupBox = new QGroupBox(tr("By Position"));
                        removekeyGroupBox = new QGroupBox(tr("or By Key"));
                        headCheckBox3     = new QCheckBox(tr("head"));
                        tailCheckBox3     = new QCheckBox(tr("tail"));
                        customSpinBox3    = new QSpinBox;
                        keyTextEdit3      = new QTextEdit;
                        customSpinBox3->setRange(2, 10);
                        keyTextEdit3->setPlaceholderText(tr("text edit"));
                        QHBoxLayout *hBoxLayout4 = new QHBoxLayout(removePosGroupBox);
                        hBoxLayout4->addWidget(headCheckBox3);
                        hBoxLayout4->addWidget(tailCheckBox3);
                        hBoxLayout4->addWidget(customSpinBox3);
                        QHBoxLayout *hBoxLayout5 = new QHBoxLayout(removekeyGroupBox);
                        hBoxLayout5->addWidget(keyTextEdit3);
                        QVBoxLayout *vBoxLayout3 = new QVBoxLayout(removeWidget);
                        vBoxLayout3->addWidget(removePosGroupBox);
                        vBoxLayout3->addWidget(removekeyGroupBox);
                        vBoxLayout3->setSpacing(20);
                
                        tabWidget = new QTabWidget;
                        tabWidget->addTab(insertWidget, tr("Insert"));
                        tabWidget->addTab(findWidget, tr("Find"));
                        tabWidget->addTab(removeWidget, tr("Remove"));
                
                        mainVBoxLayout = new QVBoxLayout(this);
                        mainVBoxLayout->addWidget(tabWidget);
                        mainVBoxLayout->addWidget(groupBox2);
                        mainVBoxLayout->setSpacing(30);
                
                        connect(headCheckBox1, SIGNAL(stateChanged(int)), this, SLOT(slot1(int)));
                        connect(tailCheckBox1, SIGNAL(stateChanged(int)), SLOT(slot2(int)));
                        connect(headCheckBox3, SIGNAL(stateChanged(int)), SLOT(slot3(int)));
                        connect(tailCheckBox3, SIGNAL(stateChanged(int)), SLOT(slot4(int)));
                        connect(tabWidget, SIGNAL(currentChanged(int)), SLOT(tabChangedReset(int)));
                
                    }
                
                    ~SingleLinkedList()
                    {}
                
                public slots:
                    void slot1(int state)
                    {
                        if (state == Qt::Checked)
                        {
                            tailCheckBox1->setCheckState(Qt::Unchecked);
                            customSpinBox1->setValue(2);
                            tailCheckBox1->setEnabled(false);
                            customSpinBox1->setEnabled(false);
                        }
                        else
                        {
                            tailCheckBox1->setEnabled(true);
                            customSpinBox1->setEnabled(true);
                        }
                    }
                
                    void slot2(int state)
                    {
                        if (state == Qt::Checked)
                        {
                            headCheckBox1->setCheckState(Qt::Unchecked);
                            customSpinBox1->setValue(2);
                            headCheckBox1->setEnabled(false);
                            customSpinBox1->setEnabled(false);
                        }
                        else
                        {
                            headCheckBox1->setEnabled(true);
                            customSpinBox1->setEnabled(true);
                        }
                    }
                
                    void slot3(int state)
                    {
                        if (state == Qt::Checked)
                        {
                            tailCheckBox3->setCheckState(Qt::Unchecked);
                            customSpinBox3->setValue(2);
                            tailCheckBox3->setEnabled(false);
                            customSpinBox3->setEnabled(false);
                        }
                        else
                        {
                            tailCheckBox3->setEnabled(true);
                            customSpinBox3->setEnabled(true);
                        }
                    }
                
                    void slot4(int state)
                    {
                        if (state == Qt::Checked)
                        {
                            headCheckBox3->setCheckState(Qt::Unchecked);
                            customSpinBox3->setValue(2);
                            headCheckBox3->setEnabled(false);
                            customSpinBox3->setEnabled(false);
                        }
                        else
                        {
                            headCheckBox3->setEnabled(true);
                            customSpinBox3->setEnabled(true);
                        }
                    }
                
                    void insertWidgetReset()
                    {
                        headCheckBox1->setCheckState(Qt::Unchecked);
                        tailCheckBox1->setCheckState(Qt::Unchecked);
                        customSpinBox1->setValue(2);
                        headCheckBox1->setEnabled(true);
                        tailCheckBox1->setEnabled(true);
                        customSpinBox1->setEnabled(true);
                        keyTextEdit1->clear();
                    }
                
                    void findWidgetReset()
                    {
                        keyTextEdit2->clear();
                    }
                
                    void removeWidgetReset()
                    {
                        headCheckBox3->setCheckState(Qt::Unchecked);
                        tailCheckBox3->setCheckState(Qt::Unchecked);
                        customSpinBox3->setValue(2);
                        headCheckBox3->setEnabled(true);
                        tailCheckBox3->setEnabled(true);
                        customSpinBox3->setEnabled(true);
                        keyTextEdit3->clear();
                    }
                
                    void tabChangedReset(int index)
                    {
                        startPushButton->setEnabled(false);
                
                        switch (index)
                        {
                        case 0:
                            insertWidgetReset();
                            break;
                        case 1:
                            findWidgetReset();
                            break;
                        case 2:
                            removeWidgetReset();
                            break;
                        }
                    }
                
                    void resetAll()
                    {
                        //insertWidgetReset(); //  jian cha yi xia
                        findWidgetReset();
                        removeWidgetReset();
                        tabWidget->setCurrentIndex(0);
                
                        reset();
                        startPushButton->setEnabled(false);
                    }
                
                private:
                    QVBoxLayout *mainVBoxLayout;
                
                    QTabWidget  *tabWidget;
                    QWidget     *insertWidget;
                    QWidget     *findWidget;
                    QWidget     *removeWidget;
                
                    QGroupBox   *insertPosGroupBox;
                    QGroupBox   *insertKeyGroupBox;
                    QCheckBox   *headCheckBox1;
                    QCheckBox   *tailCheckBox1;
                    QSpinBox    *customSpinBox1;
                    QTextEdit   *keyTextEdit1;
                
                    QGroupBox   *findKeyGroupBox;
                    QTextEdit   *keyTextEdit2;
                
                    QGroupBox   *removePosGroupBox;
                    QGroupBox   *removekeyGroupBox;
                    QCheckBox   *headCheckBox3;
                    QCheckBox   *tailCheckBox3;
                    QSpinBox    *customSpinBox3;
                    QTextEdit   *keyTextEdit3;
                };
                
                CONFIG_NAMESPACE_END
                
                #endif // CONFIG_SINGLE_LINKED_LIST
                
                
                joeQJ 1 Reply Last reply
                0
                • LimerL Limer

                  @joeQ

                  #ifndef CONFIG_BASE_H
                  #define CONFIG_BASE_H
                  
                  #include <QPushButton>
                  #include <QSlider>
                  #include <QGridLayout>
                  #include <QGroupBox>
                  
                  #define CONFIG_NAMESPACE_START namespace Config {
                  #define CONFIG_NAMESPACE_END   }
                  
                  class ConfigBase : public QWidget
                  {
                      Q_OBJECT
                  
                  public:
                      explicit ConfigBase(QWidget *parent = 0) : QWidget(parent)
                      {
                          groupBox1 = new QGroupBox(tr("Speed Control"));
                          speedSlider = new QSlider(Qt::Horizontal, groupBox1);
                          speedSlider->setMinimum(0);
                          speedSlider->setMaximum(300);
                          speedSlider->setValue(150);
                          sliderLayout = new QVBoxLayout(groupBox1);
                          sliderLayout->addWidget(speedSlider);
                  
                          groupBox2 = new QGroupBox(tr("Start && Pause"));
                          startPushButton = new QPushButton(tr("Start"));
                          pausePushButton = new QPushButton(tr("Pause"));
                          resetPushButton = new QPushButton(tr("Reset"));
                          startPushButton->setEnabled(true);
                          pausePushButton->setEnabled(false);
                          resetPushButton->setEnabled(false);
                          pushButtonLayout = new QGridLayout(groupBox2);
                          pushButtonLayout->addWidget(startPushButton, 0, 0, 1, 1);
                          pushButtonLayout->addWidget(pausePushButton, 0, 1, 1, 1);
                          pushButtonLayout->addWidget(resetPushButton, 1, 0, 1, 1);
                  
                          connect(startPushButton, SIGNAL(clicked(bool)), SLOT(start()));
                          connect(pausePushButton, SIGNAL(clicked(bool)), SLOT(pause()));
                          connect(resetPushButton, SIGNAL(clicked(bool)), SLOT(reset()));
                      }
                  
                      ~ConfigBase()
                      {}
                  
                  public slots:
                      void start()
                      {
                          startPushButton->setEnabled(false);
                          pausePushButton->setEnabled(true);
                          emit comboBoxEnabled(false);
                      }
                  
                      void pause()
                      {
                          if (pausePushButton->text() == QString(QObject::tr("Pause")))
                          {
                              pausePushButton->setText(QObject::tr("Continue"));
                              resetPushButton->setEnabled(true);
                              emit comboBoxEnabled(true);
                          }
                          else
                          {
                              pausePushButton->setText(QObject::tr("Pause"));
                              resetPushButton->setEnabled(false);
                              emit comboBoxEnabled(false);
                          }
                      }
                  
                      void reset()
                      {
                          pausePushButton->setText(QObject::tr("Pause"));
                          startPushButton->setEnabled(true);
                          pausePushButton->setEnabled(false);
                          resetPushButton->setEnabled(false);
                          speedSlider->setValue(150);
                          emit comboBoxEnabled(true);
                      }
                  
                  signals:
                      void comboBoxEnabled(bool);
                  
                  public:
                      QPushButton *startPushButton;
                      QPushButton *pausePushButton;
                      QPushButton *resetPushButton;
                      QSlider     *speedSlider;
                  
                  protected:
                      QGroupBox   *groupBox1;
                      QGroupBox   *groupBox2;
                  
                  private:
                      QVBoxLayout *sliderLayout;
                      QGridLayout *pushButtonLayout;
                  };
                  
                  #endif // CONFIG_BASE_H
                  
                  
                  #ifndef CONFIG_SINGLE_LINKED_LIST
                  #define CONFIG_SINGLE_LINKED_LIST
                  
                  #include <QCheckBox>
                  #include <QSpinBox>
                  #include <QTabWidget>
                  #include <QTextEdit>
                  #include "config_base.h"
                  
                  CONFIG_NAMESPACE_START
                  
                  class SingleLinkedList : public ConfigBase
                  {
                      Q_OBJECT
                  
                  public:
                      explicit SingleLinkedList(ConfigBase *parent = 0) : ConfigBase(parent)
                      {
                          delete groupBox1;
                          startPushButton->setEnabled(false);
                  
                          insertWidget      = new QWidget;
                          insertPosGroupBox = new QGroupBox(tr("Position"));
                          insertKeyGroupBox = new QGroupBox(tr("Key"));
                          headCheckBox1     = new QCheckBox(tr("head"));
                          tailCheckBox1     = new QCheckBox(tr("tail"));
                          keyTextEdit1      = new QTextEdit;
                          customSpinBox1    = new QSpinBox;
                          keyTextEdit1->setPlaceholderText(tr("key text edit"));
                          customSpinBox1->setRange(2, 10);
                          QHBoxLayout *hBoxLayout1 = new QHBoxLayout(insertPosGroupBox);
                          hBoxLayout1->addWidget(headCheckBox1);
                          hBoxLayout1->addWidget(tailCheckBox1);
                          hBoxLayout1->addWidget(customSpinBox1);
                          QHBoxLayout *hBoxLayout2 = new QHBoxLayout(insertKeyGroupBox);
                          hBoxLayout2->addWidget(keyTextEdit1);
                          QVBoxLayout *vBoxLayout1 = new QVBoxLayout(insertWidget);
                          vBoxLayout1->addWidget(insertPosGroupBox);
                          vBoxLayout1->addWidget(insertKeyGroupBox);
                          vBoxLayout1->setSpacing(20);
                  
                          findWidget       = new QWidget;
                          findKeyGroupBox  = new QGroupBox(tr("Key"));
                          keyTextEdit2     = new QTextEdit;
                          keyTextEdit2->setPlaceholderText(tr("key text edit"));
                          QHBoxLayout *hBoxLayout3 = new QHBoxLayout(findKeyGroupBox);
                          hBoxLayout3->addWidget(keyTextEdit2);
                          QVBoxLayout *vBoxLayout2 = new QVBoxLayout(findWidget);
                          vBoxLayout2->addWidget(findKeyGroupBox);
                  
                          removeWidget      = new QWidget;
                          removePosGroupBox = new QGroupBox(tr("By Position"));
                          removekeyGroupBox = new QGroupBox(tr("or By Key"));
                          headCheckBox3     = new QCheckBox(tr("head"));
                          tailCheckBox3     = new QCheckBox(tr("tail"));
                          customSpinBox3    = new QSpinBox;
                          keyTextEdit3      = new QTextEdit;
                          customSpinBox3->setRange(2, 10);
                          keyTextEdit3->setPlaceholderText(tr("text edit"));
                          QHBoxLayout *hBoxLayout4 = new QHBoxLayout(removePosGroupBox);
                          hBoxLayout4->addWidget(headCheckBox3);
                          hBoxLayout4->addWidget(tailCheckBox3);
                          hBoxLayout4->addWidget(customSpinBox3);
                          QHBoxLayout *hBoxLayout5 = new QHBoxLayout(removekeyGroupBox);
                          hBoxLayout5->addWidget(keyTextEdit3);
                          QVBoxLayout *vBoxLayout3 = new QVBoxLayout(removeWidget);
                          vBoxLayout3->addWidget(removePosGroupBox);
                          vBoxLayout3->addWidget(removekeyGroupBox);
                          vBoxLayout3->setSpacing(20);
                  
                          tabWidget = new QTabWidget;
                          tabWidget->addTab(insertWidget, tr("Insert"));
                          tabWidget->addTab(findWidget, tr("Find"));
                          tabWidget->addTab(removeWidget, tr("Remove"));
                  
                          mainVBoxLayout = new QVBoxLayout(this);
                          mainVBoxLayout->addWidget(tabWidget);
                          mainVBoxLayout->addWidget(groupBox2);
                          mainVBoxLayout->setSpacing(30);
                  
                          connect(headCheckBox1, SIGNAL(stateChanged(int)), this, SLOT(slot1(int)));
                          connect(tailCheckBox1, SIGNAL(stateChanged(int)), SLOT(slot2(int)));
                          connect(headCheckBox3, SIGNAL(stateChanged(int)), SLOT(slot3(int)));
                          connect(tailCheckBox3, SIGNAL(stateChanged(int)), SLOT(slot4(int)));
                          connect(tabWidget, SIGNAL(currentChanged(int)), SLOT(tabChangedReset(int)));
                  
                      }
                  
                      ~SingleLinkedList()
                      {}
                  
                  public slots:
                      void slot1(int state)
                      {
                          if (state == Qt::Checked)
                          {
                              tailCheckBox1->setCheckState(Qt::Unchecked);
                              customSpinBox1->setValue(2);
                              tailCheckBox1->setEnabled(false);
                              customSpinBox1->setEnabled(false);
                          }
                          else
                          {
                              tailCheckBox1->setEnabled(true);
                              customSpinBox1->setEnabled(true);
                          }
                      }
                  
                      void slot2(int state)
                      {
                          if (state == Qt::Checked)
                          {
                              headCheckBox1->setCheckState(Qt::Unchecked);
                              customSpinBox1->setValue(2);
                              headCheckBox1->setEnabled(false);
                              customSpinBox1->setEnabled(false);
                          }
                          else
                          {
                              headCheckBox1->setEnabled(true);
                              customSpinBox1->setEnabled(true);
                          }
                      }
                  
                      void slot3(int state)
                      {
                          if (state == Qt::Checked)
                          {
                              tailCheckBox3->setCheckState(Qt::Unchecked);
                              customSpinBox3->setValue(2);
                              tailCheckBox3->setEnabled(false);
                              customSpinBox3->setEnabled(false);
                          }
                          else
                          {
                              tailCheckBox3->setEnabled(true);
                              customSpinBox3->setEnabled(true);
                          }
                      }
                  
                      void slot4(int state)
                      {
                          if (state == Qt::Checked)
                          {
                              headCheckBox3->setCheckState(Qt::Unchecked);
                              customSpinBox3->setValue(2);
                              headCheckBox3->setEnabled(false);
                              customSpinBox3->setEnabled(false);
                          }
                          else
                          {
                              headCheckBox3->setEnabled(true);
                              customSpinBox3->setEnabled(true);
                          }
                      }
                  
                      void insertWidgetReset()
                      {
                          headCheckBox1->setCheckState(Qt::Unchecked);
                          tailCheckBox1->setCheckState(Qt::Unchecked);
                          customSpinBox1->setValue(2);
                          headCheckBox1->setEnabled(true);
                          tailCheckBox1->setEnabled(true);
                          customSpinBox1->setEnabled(true);
                          keyTextEdit1->clear();
                      }
                  
                      void findWidgetReset()
                      {
                          keyTextEdit2->clear();
                      }
                  
                      void removeWidgetReset()
                      {
                          headCheckBox3->setCheckState(Qt::Unchecked);
                          tailCheckBox3->setCheckState(Qt::Unchecked);
                          customSpinBox3->setValue(2);
                          headCheckBox3->setEnabled(true);
                          tailCheckBox3->setEnabled(true);
                          customSpinBox3->setEnabled(true);
                          keyTextEdit3->clear();
                      }
                  
                      void tabChangedReset(int index)
                      {
                          startPushButton->setEnabled(false);
                  
                          switch (index)
                          {
                          case 0:
                              insertWidgetReset();
                              break;
                          case 1:
                              findWidgetReset();
                              break;
                          case 2:
                              removeWidgetReset();
                              break;
                          }
                      }
                  
                      void resetAll()
                      {
                          //insertWidgetReset(); //  jian cha yi xia
                          findWidgetReset();
                          removeWidgetReset();
                          tabWidget->setCurrentIndex(0);
                  
                          reset();
                          startPushButton->setEnabled(false);
                      }
                  
                  private:
                      QVBoxLayout *mainVBoxLayout;
                  
                      QTabWidget  *tabWidget;
                      QWidget     *insertWidget;
                      QWidget     *findWidget;
                      QWidget     *removeWidget;
                  
                      QGroupBox   *insertPosGroupBox;
                      QGroupBox   *insertKeyGroupBox;
                      QCheckBox   *headCheckBox1;
                      QCheckBox   *tailCheckBox1;
                      QSpinBox    *customSpinBox1;
                      QTextEdit   *keyTextEdit1;
                  
                      QGroupBox   *findKeyGroupBox;
                      QTextEdit   *keyTextEdit2;
                  
                      QGroupBox   *removePosGroupBox;
                      QGroupBox   *removekeyGroupBox;
                      QCheckBox   *headCheckBox3;
                      QCheckBox   *tailCheckBox3;
                      QSpinBox    *customSpinBox3;
                      QTextEdit   *keyTextEdit3;
                  };
                  
                  CONFIG_NAMESPACE_END
                  
                  #endif // CONFIG_SINGLE_LINKED_LIST
                  
                  
                  joeQJ Offline
                  joeQJ Offline
                  joeQ
                  wrote on last edited by
                  #8

                  @Limer

                  Try include QWidget in ConfigBase head file.
                  and Try include QObject in SingleLinkedList head file.

                  run qmake again.

                  Just do it!

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

                    Hi
                    The code is fine. Compiles here.
                    So if still complaining, then completely delete the build folder.

                    alt text

                    LimerL 1 Reply Last reply
                    0
                    • joeQJ joeQ

                      @Limer

                      Try include QWidget in ConfigBase head file.
                      and Try include QObject in SingleLinkedList head file.

                      run qmake again.

                      LimerL Offline
                      LimerL Offline
                      Limer
                      wrote on last edited by Limer
                      #10

                      @joeQ

                      I tried, failed. this is all project : https://pan.baidu.com/s/1c2hNztm

                      1 Reply Last reply
                      0
                      • mrjjM mrjj

                        Hi
                        The code is fine. Compiles here.
                        So if still complaining, then completely delete the build folder.

                        alt text

                        LimerL Offline
                        LimerL Offline
                        Limer
                        wrote on last edited by Limer
                        #11

                        @mrjj

                        I had deleted all build* file, but failed again and same errors. this is all project : https://pan.baidu.com/s/1c2hNztm

                        1 Reply Last reply
                        0
                        • Paul ColbyP Offline
                          Paul ColbyP Offline
                          Paul Colby
                          wrote on last edited by
                          #12

                          Hi @Limer,

                          The problem appears to be that you have two SingleLinkedList classes. Although they are in two separate namespaces, for whatever reason (not sure its a bug, or a known limitation), QMake is only producing a moc file for one of them - if you rename either source file, the moc will be for the other.

                          I'd suggest you rename one of those classes.

                          Cheers.

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

                            Hi
                            You have the file single_linked_list.h in two folders
                            moc seems them as one
                            NMAKE:-1: warning: U4004: too many rules for target 'debug\moc_single_linked_list.cpp'

                            so rename one of the files and it works. you can do it directly in project explorer and all
                            is changed correctly.

                            alt text

                            alt text

                            ahh @Paul-Colby beat me to it :)

                            LimerL 1 Reply Last reply
                            4
                            • mrjjM mrjj

                              Hi
                              You have the file single_linked_list.h in two folders
                              moc seems them as one
                              NMAKE:-1: warning: U4004: too many rules for target 'debug\moc_single_linked_list.cpp'

                              so rename one of the files and it works. you can do it directly in project explorer and all
                              is changed correctly.

                              alt text

                              alt text

                              ahh @Paul-Colby beat me to it :)

                              LimerL Offline
                              LimerL Offline
                              Limer
                              wrote on last edited by
                              #14

                              @mrjj @Paul Colby

                              Thanks, it`s ok!

                              1 Reply Last reply
                              2

                              • Login

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