plopes21
18th June 2012, 12:31
Good morning people,
I'm with a problem threading.
I want to start multiple threads at program start and I am not getting.
In mainwindow.ccp have the following.
MainWindow.cpp
* The alarm;
a.run ();
Class Alarm
class Alarm : public QThread
{
Q_OBJECT
public:
Alarm(QObject* = 0);
void iniciarValoresAlarme();
void run();
signals:
void itsTime();
};
#endif
Alarm.cpp
Alarm::Alarm(QObject* parent) :
QThread(parent)
{}
void Alarm::run(){
exec();
}
void Alarm::iniciarValoresAlarme()
{
QDateTime today = QDateTime::currentDateTime();
year = today.date().year();
month = today.date().month();
day = today.date().day();
// hours = 0;
// minutes = 0;
seconds = 0;
timeToAlarm = 0;
timer = new QTimer(this);
connect(timer, SIGNAL(timeout()), this, SLOT(finalizarAlarm()));
connect(this,SIGNAL(itsTime()),this,SLOT(launchAla rm()));
iniciarAlarme();
start();
qDebug()<<"Depois do start antes do wait";
wait();
}
this code don´t work.
What the problem?
I'm with a problem threading.
I want to start multiple threads at program start and I am not getting.
In mainwindow.ccp have the following.
MainWindow.cpp
* The alarm;
a.run ();
Class Alarm
class Alarm : public QThread
{
Q_OBJECT
public:
Alarm(QObject* = 0);
void iniciarValoresAlarme();
void run();
signals:
void itsTime();
};
#endif
Alarm.cpp
Alarm::Alarm(QObject* parent) :
QThread(parent)
{}
void Alarm::run(){
exec();
}
void Alarm::iniciarValoresAlarme()
{
QDateTime today = QDateTime::currentDateTime();
year = today.date().year();
month = today.date().month();
day = today.date().day();
// hours = 0;
// minutes = 0;
seconds = 0;
timeToAlarm = 0;
timer = new QTimer(this);
connect(timer, SIGNAL(timeout()), this, SLOT(finalizarAlarm()));
connect(this,SIGNAL(itsTime()),this,SLOT(launchAla rm()));
iniciarAlarme();
start();
qDebug()<<"Depois do start antes do wait";
wait();
}
this code don´t work.
What the problem?