Hello,
I want to pass some data from a sub thread to the main thread (GUI).
So I decided to emit a signal from the thread. The signal shall have an object containing the data as argument.
The main thread has a slot with the identical signature (means: expects an object as argument).
// The signal declarationin of the sub thread class:
signals:
void newLineConstructed( MyTableWidgetRow );
// The slot definition in the main thread class:
public slots:
void AddNewElementsLine( MyTableWidgetRow newRow );
// The "connect" statement used:
connect( m_updateElementsThread, SIGNAL(newLineConstructed(MyTableWidgetRow)),
this, SLOT(AddNewElementsLine(MyTableWidgetRow)) );
// The signal declarationin of the sub thread class:
signals:
void newLineConstructed( MyTableWidgetRow );
// The slot definition in the main thread class:
public slots:
void AddNewElementsLine( MyTableWidgetRow newRow );
// The "connect" statement used:
connect( m_updateElementsThread, SIGNAL(newLineConstructed(MyTableWidgetRow)),
this, SLOT(AddNewElementsLine(MyTableWidgetRow)) );
To copy to clipboard, switch view to plain text mode
"MyTableWidgetRow" is a class.
m_updateElementsThread is an instance of a class derived from QThread that declares the above described signal.
"this" is the main thread. The connecting code is therefore in the constructor of the main thread.
The slot is never called when the signal is emited (and yes, it is emited in my code).
When I change the aguments type from MyTableWidgetRow to int, the slot is called, but not with my class as argument.
Any ideas what could be wrong?
What more information do you need th "analyze" what could be wrong?
Bookmarks