L
L
l2p2014-09-07 14:12:00
Qt
l2p, 2014-09-07 14:12:00

How to implement connect in a separate class?

In the generated class (new .h) created a slot. I tried to connect it with a connection to the timer, which is declared in the same class, but without success.

\rounds.h:56: ошибка: no matching function for call to 'QObject::connect(QTimer*&, const char [11], CCClass* const, const char [14])'
         QObject::connect(Timer, SIGNAL(timeout()), this, SLOT(Time()));

As I understand it, this does not work, because QTimer* Timer = new QTimer(); it works without this, but not with it.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Stanislav Silin, 2014-09-07
@l2p

You need to inherit your class from the desired Qt class and add the Q_OBJECT macro.

class Round : public QDialog //или другой Qt класс
{
     Q_OBJECT
//...

Then it will be possible to use signal and slot.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question