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. [solved] Object::connect: No such slot

[solved] Object::connect: No such slot

Scheduled Pinned Locked Moved General and Desktop
6 Posts 3 Posters 12.0k 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.
  • D Offline
    D Offline
    deleted28
    wrote on last edited by
    #1

    I modified the example "Configuration Dialog" (from Qt 4.8/ creator2.8)
    for learning by doing. On a QPushbutton clicked event on one of the pages
    of a QStackedWidget a short message should be printed out.
    I'm not able to set the connect SIGNAL correctly. What is wrong here ?
    @class TestPage : public QWidget
    {
    public:
    TestPage(QWidget *parent = 0);

    private:
    QPushButton *pb_1 ;
    QPushButton *pb_2 ;
    QPushButton *pb_go;

    private slots:
    void xxx();

    };@

    @TestPage::TestPage(QWidget *parent)
    : QWidget(parent)
    {

    QGroupBox *gb_avalPorts = new QGroupBox("Availabe ports");
    
    pb_1 = new QPushButton("1");
    pb_2 = new QPushButton("2");
    
    QVBoxLayout *sniffLayout = new QVBoxLayout;
    sniffLayout->addWidget(pb_1);
    sniffLayout->addWidget(pb_2);
    gb_avalPorts->setLayout(sniffLayout);
    
    pb_go = new QPushButton("Go");
    
    QVBoxLayout *mainLayout = new QVBoxLayout;
    mainLayout->addWidget(gb_avalPorts);
    mainLayout->addWidget(pb_go);
    mainLayout->addSpacing(12);
    

    // mainLayout->addStretch(1);
    setLayout(mainLayout);

    connect(pb_go, SIGNAL(clicked()), this, SLOT(xxx()));
    

    }

    void TestPage::xxx()
    {
    qDebug() << "bingo";

    }
    @

    immediately on startup i get message:
    Object::connect: No such slot QWidget::xxx()

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

      Hi,

      You are missing the Q_OBJECT macro in your class declaration

      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
      0
      • D Offline
        D Offline
        deleted28
        wrote on last edited by
        #3

        Never would find this without your hint, thx.
        but now:
        pages.cpp:-1: error: undefined reference to `vtable for TestPage'

        i just addes line 3

        @class TestPage : public QWidget
        {
        Q_OBJECT

        public:
        TestPage(QWidget *parent = 0);

        private:
        QPushButton *pb_1 ;
        QPushButton *pb_2 ;
        QPushButton *pb_go;

        private slots:
        void xxx();

        };@

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

          You need to run qmake when you add/remove the Q_OBJECT macro before building

          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
          0
          • K Offline
            K Offline
            koahnig
            wrote on last edited by
            #5

            Probably a good idea to "rerun qmake" and "rebuild".

            Vote the answer(s) that helped you to solve your issue(s)

            1 Reply Last reply
            0
            • D Offline
              D Offline
              deleted28
              wrote on last edited by
              #6

              Yup ! Great ! Thank you !

              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