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
{
Q_OBJECTpublic:
explicit plugin_test(QWidget *parent = 0);
~plugin_test();private:
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) :
QDialog(parent),
ui(new Ui::plugin_test)
{ui->setupUi(this); connect(ui->startButton, SIGNAL(clicked()), this, SLOT(startCompteur()));
}
plugin_test::~plugin_test()
{
delete ui;
}void plugin_test::startCompteur()
{
//here my code
}thanks for your help
-
Hi and welcome to devnet,
Pretty strange, did you do anything beside adding the slot to your class ?
-
@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());
or
connect(ui->startButton, SIGNAL(&sender::pressed()), this, SLOT(&receivers::startCompteur()));
or maybe i've not totally understood...
Anyways these synthaxes still doesn't work
-
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 -
@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);