I'm using QTimer in QThread( or QObject ) class :
class InfoThread: public QThreed
{
Q_OBJECT
...
void run();
signals:
void newInfoAvalible( /* some data */ );
private slots:
void update();
..
private:
};
{
connect( p_timer, SIGNAL( timeout() ), this, SLOT( update() ) );
}
void InfoThread::run()
{
p_timer->start( 1000 );
exec(); // event loop for QTimer
}
void InfoThread::update()
{
...
emit newInfoAvalible( /* some data */ );
}
class InfoThread: public QThreed
{
Q_OBJECT
...
void run();
signals:
void newInfoAvalible( /* some data */ );
private slots:
void update();
..
private:
QTimer *p_timer;
};
InfoThread::Infothread( QObject *parent ) : QThread( parent )
{
p_timer = new QTimer( this );
connect( p_timer, SIGNAL( timeout() ), this, SLOT( update() ) );
}
void InfoThread::run()
{
p_timer->start( 1000 );
exec(); // event loop for QTimer
}
void InfoThread::update()
{
...
emit newInfoAvalible( /* some data */ );
}
To copy to clipboard, switch view to plain text mode
For me code is good, but signal newInfoAvalible( /* some data */ ) causes apps to crash. Wher's the problem?
Bookmarks