{
Q_OBJECT
...
public slots:
void showResponse
( const QString &stringResponse
);
void processError
( const QString &stringError
);
void processTimeout
( const QString &stringTimeout
);
...
}
{
Q_OBJECT
...
signals:
...
}
The direction of communication is child to parent and is thus a great reason to use signals and slots. But how do I set this up?
MyThread::MyDialog ( QQDialog* parent ) <--should i do this in MyThread or MyDialog?
: ...
{
...
connect ( &m_threadATMega328p_RS232,
SIGNAL ( response
( QString ) ), m_signalMapper,
SLOT ( map
() ) );
m_signalMapper->setMapping ( this, 0 ); // 0 is an ID but how do you reference 0 or 1 or 2? How do you map this to that?
//connect ( m_signalMapper, SIGNAL ( mapped ( QString ) ), this, SIGNAL ( response ( const QString & ) ) );
connect ( m_signalMapper,
SIGNAL ( mapped
( QString ) ),
this,
SLOT ( showResponse
( QString ) ) );
...
}
class MyDialog : public QDialog
{
Q_OBJECT
...
public slots:
void showResponse ( const QString &stringResponse );
void processError ( const QString &stringError );
void processTimeout ( const QString &stringTimeout );
...
}
class MyThread : public QThread
{
Q_OBJECT
...
signals:
void response ( const QString & );
void error ( const QString & );
void timeout ( const QString & );
...
}
The direction of communication is child to parent and is thus a great reason to use signals and slots. But how do I set this up?
MyThread::MyDialog ( QQDialog* parent ) <--should i do this in MyThread or MyDialog?
: ...
{
...
m_signalMapper = new QSignalMapper (); // parent or this?
connect ( &m_threadATMega328p_RS232, SIGNAL ( response ( QString ) ), m_signalMapper, SLOT ( map () ) );
m_signalMapper->setMapping ( this, 0 ); // 0 is an ID but how do you reference 0 or 1 or 2? How do you map this to that?
//connect ( m_signalMapper, SIGNAL ( mapped ( QString ) ), this, SIGNAL ( response ( const QString & ) ) );
connect ( m_signalMapper, SIGNAL ( mapped ( QString ) ), this, SLOT ( showResponse ( QString ) ) );
...
}
To copy to clipboard, switch view to plain text mode
Bookmarks