just copy pasted your example and it works for me.
tst.h
class abstract_therapy
: public QObject{
Q_OBJECT
public:
void testFunction();
public slots:
void testSlot(){ qDebug() << "in slot"; }
private:
};
class B : public abstract_therapy
{
Q_OBJECT
public:
void abc(){}
};
class abstract_therapy : public QObject
{
Q_OBJECT
public:
void testFunction();
public slots:
void testSlot(){ qDebug() << "in slot"; }
private:
QTimer* m1;
};
class B : public abstract_therapy
{
Q_OBJECT
public:
void abc(){}
};
To copy to clipboard, switch view to plain text mode
main.cpp
#include <QtCore>
#include "tst.h"
void abstract_therapy::testFunction()
{
m1->connect(m1, SIGNAL(timeout()), this, SLOT(testSlot()));
m1->setInterval(500);
m1->start();
}
int main(int argc, char *argv[])
{
abstract_therapy* _therapy;
_therapy = new B;
_therapy->testFunction();
return a.exec();
}
#include <QtCore>
#include "tst.h"
void abstract_therapy::testFunction()
{
m1 = new QTimer(this);
m1->connect(m1, SIGNAL(timeout()), this, SLOT(testSlot()));
m1->setInterval(500);
m1->start();
}
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
abstract_therapy* _therapy;
_therapy = new B;
_therapy->testFunction();
return a.exec();
}
To copy to clipboard, switch view to plain text mode
and here is the output
Starting /home/nish/Desktop/progs/tst/tst-build-desktop/tst...
in slot
in slot
in slot
in slot
in slot
in slot
in slot
in slot
in slot
in slot
in slot
in slot
in slot
in slot
Bookmarks