QT no such slot with Q_Object

  • Hi everyone,

    I have some issue on Qt 5.5, when i want to add a slot to my class :

    QObject::connect: No such slot plugin_test::startCompteur()
    QObject::connect: (sender name: 'startButton')
    QObject::connect: (receiver name: 'plugin_test')

    #ifndef PLUGIN_TEST_H
    #define PLUGIN_TEST_H

    #include <QDialog>

    namespace Ui {
    class plugin_test;

    class plugin_test : public QDialog

    explicit plugin_test(QWidget *parent = 0);

    Ui::plugin_test *ui;

    private slots :

    void startCompteur();

    #endif // PLUGIN_TEST_H

    #include "plugin_test.h"
    #include "ui_plugin_test.h"

    #include "capture_file.h"

    #include <config.h>

    #include "cfile.h"
    #include "file.h"
    #include "fileset.h"

    plugin_test::plugin_test(QWidget *parent) :
    ui(new Ui::plugin_test)

    connect(ui->startButton, SIGNAL(clicked()), this, SLOT(startCompteur()));


    delete ui;

    void plugin_test::startCompteur()
    //here my code

    thanks for your help

  • Lifetime Qt Champion

    Hi and welcome to devnet,

    Pretty strange, did you do anything beside adding the slot to your class ?

  • Hmm just guessing, perhaps some name collision with the Wireshark include files?
    Try some other name than startCompteur()...

  • SGaist :

    I'm working on wireshark source code and i've just add a new class with one slot.

    hskoglund :

    I already tried with another name like test_slot that i'm pretty sur there is no similar name but still doesn't work.

  • Qt Champions 2016

    @Hystreal said:

    And its not because its private and you hook it up in Dialog ?
    maybe try with new syntax ?
    connect(sender, &Sender::valueChanged, receiver, &Receiver::updateValue );

    since it gives better warnings/more type strict.

  • Did you mean this synthax without SIGNAL and SLOT ?

    connect(ui->startButton, &sender::pressed(), this, &receivers::startCompteur());


    connect(ui->startButton, SIGNAL(&sender::pressed()), this, SLOT(&receivers::startCompteur()));

    or maybe i've not totally understood...

    Anyways these synthaxes still doesn't work

  • Moderators


    connect(ui->startButton, &sender::pressed(), this, &receivers::startCompteur()); is wrong, it should be:
    connect(ui->startButton, &sender::pressed, this, &receivers::startCompteur);

  • OK, i tried and now i have the followings errors :

    erreur : C2653: 'sender' : is not a class or namespace name
    erreur : C2065: 'pressed' : undeclared identifier
    erreur : C2653: 'receivers' : is not a class or namespace name
    erreur : C2276: '&' : illegal operation on bound member function expression

  • Moderators

    @Hystreal That's because you are doing it completely wrong, it should be (don't know what the class is where startCompteur is, change it accordingly):

    connect(ui->startButton, &QPushButton::pressed, this, &Receiver::startCompteur);

  • Ok sorry , it works now ! thanks you very much !

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.