I made a class in a header file.
the class declaration:
class myTimer : public QObject
{
Q_OBJECT
~snipped~
I have a custom slot:
private slots:
void mySlot();
and a custom signal:
signals:
QString mySignal();
The slot simply emits mySignal
which then returns a QString
.
I connect a QPushButton
with mySlot
:
connect(ui->startButton, SIGNAL(clicked()),
timer, SLOT(mySlot()));
and mySignal
to a LCD number:
connect(timer, SIGNAL(mySignal()),
ui->lcdNumber, SLOT(display(QString)));
Here timer
is the object of the class I've declared. In both the connect statements I'm getting the error unable to convert parameter to const QObject*
pointing to the object 'timer'.
I don't know why this error is occurring even though I have properly derieved from QObject adn added Q_OBJECT macro.
timer
exactly? – Matconnect
call expects the signal to provide aQString
- which it doesn't. The signals carry their data as arguments, not return values (see a simple example: qt-project.org/doc/qt-5/signalsandslots.html#a-small-example). – cmannett85