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

QObject::connect: No such slot

Scheduled Pinned Locked Moved Solved General and Desktop
3 Posts 2 Posters 1.7k 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.
  • J Offline
    J Offline
    juve938383
    wrote on last edited by juve938383
    #1

    Hello!
    I am using a connect function but it will not recognize my variable as a slot even though it is such. Here is a part of the code.

    gameclass.h

    class   GameLoop : public QGraphicsView
    {
    ...
    public slots:
        void                                    multiply_ghosts();
    };
    
    

    gameclass.cpp

    #include "gameclass.h"
    
    void    GameLoop::ft_roll_game()
    {
        timer_multi = new QTimer();
        QObject::connect(timer_multi, SIGNAL(timeout()), this, SLOT(multiply_ghosts()));
        timer_multi->start(3000);
    }
    
    void    GameLoop::multiply_ghosts(){
        std::cout<<"Multiplying";
    }
    

    I get this warning and the message does not show in console(which means the timer is not working):
    qt.core.qobject.connect: QObject::connect: No such slot QGraphicsView::multiply_ghosts() in ..

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

      Switch to the new(er) connect syntax so you may get a more detailed error message at compile time instead of run time:

      QObject::connect(timer_multi, &QTimer::timeout, this, &GameLoop::multiply_ghosts);
      

      Also, you didn't show all of your GameLoop header, does it include the Q_OBJECT macro?

      1 Reply Last reply
      3
      • J Offline
        J Offline
        juve938383
        wrote on last edited by
        #3

        Thanks! It worked thanks to the newer syntax.

        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