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. Object::connect: No such slot [SOLVED]
Forum Updated to NodeBB v4.3 + New Features

Object::connect: No such slot [SOLVED]

Scheduled Pinned Locked Moved General and Desktop
5 Posts 3 Posters 5.1k 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.
  • S Offline
    S Offline
    Stanislav
    wrote on last edited by Stanislav
    #1

    whe I start program this shows in console "Object::connect: No such slot QMainWindow::Refresh() in /home/default/projects/MainProject/WindowDiscoverServer.cpp:10
    Object::connect: (sender name: 'ButtonRefresh')
    Object::connect: (receiver name: 'MainWindow') "

    WindowDiscoverServer.h
    [code]
    class WindowDiscoverServer : public QMainWindow
    {

    //Q_OBJECT

    public:
    WindowDiscoverServer(QWidget* parent = 0);
    virtual ~WindowDiscoverServer();

    public slots:
    void Refresh();

    private:

    Ui_MainWindow *ui;

    };
    [/code]

    WindowDiscoverServer.cpp
    [code]
    WindowDiscoverServer::WindowDiscoverServer(QWidget* parent): QMainWindow(parent), ui(new Ui_MainWindow)
    {
    ui->setupUi(this);

    QObject::connect(ui->ButtonQuit, SIGNAL(clicked()), this, SLOT(close()));
    QObject::connect(ui->ButtonRefresh, SIGNAL(clicked()), this, SLOT(Refresh()));
    }
    WindowDiscoverServer::~WindowDiscoverServer()
    {
    delete ui;
    }

    void WindowDiscoverServer::Refresh()
    {
    std::cout << "Refresh " << std::endl;
    }
    [/code]

    JKSHJ 1 Reply Last reply
    0
    • M Offline
      M Offline
      mcosta
      wrote on last edited by
      #2

      Hi,

      to use signals/slots you have to uncomment Q_OBJECT inside your class definition

      Once your problem is solved don't forget to:

      • Mark the thread as SOLVED using the Topic Tool menu
      • Vote up the answer(s) that helped you to solve the issue

      You can embed images using (http://imgur.com/) or (http://postimage.org/)

      1 Reply Last reply
      0
      • S Stanislav

        whe I start program this shows in console "Object::connect: No such slot QMainWindow::Refresh() in /home/default/projects/MainProject/WindowDiscoverServer.cpp:10
        Object::connect: (sender name: 'ButtonRefresh')
        Object::connect: (receiver name: 'MainWindow') "

        WindowDiscoverServer.h
        [code]
        class WindowDiscoverServer : public QMainWindow
        {

        //Q_OBJECT

        public:
        WindowDiscoverServer(QWidget* parent = 0);
        virtual ~WindowDiscoverServer();

        public slots:
        void Refresh();

        private:

        Ui_MainWindow *ui;

        };
        [/code]

        WindowDiscoverServer.cpp
        [code]
        WindowDiscoverServer::WindowDiscoverServer(QWidget* parent): QMainWindow(parent), ui(new Ui_MainWindow)
        {
        ui->setupUi(this);

        QObject::connect(ui->ButtonQuit, SIGNAL(clicked()), this, SLOT(close()));
        QObject::connect(ui->ButtonRefresh, SIGNAL(clicked()), this, SLOT(Refresh()));
        }
        WindowDiscoverServer::~WindowDiscoverServer()
        {
        delete ui;
        }

        void WindowDiscoverServer::Refresh()
        {
        std::cout << "Refresh " << std::endl;
        }
        [/code]

        JKSHJ Offline
        JKSHJ Offline
        JKSH
        Moderators
        wrote on last edited by
        #3

        Hi, and welcome to the Qt Dev Net!

        @Stanislav said:

        WindowDiscoverServer.h

        class WindowDiscoverServer : public QMainWindow 
        {
        
          //Q_OBJECT
        

        Why did you comment out the Q_OBJECT macro? Your class needs it to implement new slots.

        Un-comment the macro and run qmake.

        Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

        1 Reply Last reply
        0
        • S Offline
          S Offline
          Stanislav
          wrote on last edited by
          #4

          when i uncomment my compilator (Kdevelop) return this error "/home/default/projects/MainProject/WindowDiscoverServer.cpp:5: undefined reference to `vtable for WindowDiscoverServer'

          p.s. I use cmake not qmake

          JKSHJ 1 Reply Last reply
          0
          • S Stanislav

            when i uncomment my compilator (Kdevelop) return this error "/home/default/projects/MainProject/WindowDiscoverServer.cpp:5: undefined reference to `vtable for WindowDiscoverServer'

            p.s. I use cmake not qmake

            JKSHJ Offline
            JKSHJ Offline
            JKSH
            Moderators
            wrote on last edited by JKSH
            #5

            @Stanislav said:

            when i uncomment my compilator (Kdevelop) return this error "/home/default/projects/MainProject/WindowDiscoverServer.cpp:5: undefined reference to `vtable for WindowDiscoverServer'

            Yes, that's why I said you need to run qmake after you uncomment it.

            p.s. I use cmake not qmake

            I don't know how to do it in cmake, but you can (i) uncomment Q_OBJECT, (ii) delete your build tree, and then then (iii) rebuild everything from the beginning.

            Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

            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