Geez, not only do you bring back from the dead a 6+ years-old post, you post an absolutely terrible solution that is completely counter to what Qt signals and slots are all about.
You should never, ever implement code like this in a Qt app.
If you have two classes where one of them needs to send information that updates the UI on the other, then you do it this way:
1 - Implement a slot on the UI class:
void MyUIClass
::updateText( const QString & newText
) {
ui->textEdit->setText( newText );
}
void MyUIClass::updateText( const QString & newText )
{
ui->textEdit->setText( newText );
}
To copy to clipboard, switch view to plain text mode
2 - Implement a signal in the class that needs to send the text to the UI class:
signals:
void sendText
( const QString & newText
);
signals:
void sendText( const QString & newText );
To copy to clipboard, switch view to plain text mode
3 - Connect the signal to the slot:
connect( myClass,
SIGNAL( sendText
( const QString & ) ), myUIClass,
SLOT( updateText
( const QString & ) ) );
connect( myClass, SIGNAL( sendText( const QString & ) ), myUIClass, SLOT( updateText( const QString & ) ) );
To copy to clipboard, switch view to plain text mode
4 - and every time "myClass" needs to display a new message on the UI class, it simply calls:
emit sendText( "Here is new text" );
emit sendText( "Here is new text" );
To copy to clipboard, switch view to plain text mode
Bookmarks