To post data from thread to gui i used custom QEvent... here is example:
{
public:
printE
(QString str, Type type
=(QEvent::Type)1001);
// here should be int between 1000 and 65535 Type type();
private:
Type t;
};
{
t = type;
string = str;
}
{
return t;
}
{
return string;
}
class printE: public QEvent
{
public:
printE(QString str, Type type=(QEvent::Type)1001); // here should be int between 1000 and 65535
Type type();
QString data();
private:
Type t;
QString string;
};
printE::printE(QString str, Type type):QEvent(type)
{
t = type;
string = str;
}
QEvent::Type printE::type()
{
return t;
}
QString printE::data()
{
return string;
}
To copy to clipboard, switch view to plain text mode
Of course you can add much more data into this event... In your customEvent(QEvent *e) you should place something like that to recieve data from your custom event
if(e
->type
() == (QEvent::Type)1001) {
// do something with str
}
if(e->type() == (QEvent::Type)1001)
{
QString str=((printE*)e)->data();
// do something with str
}
To copy to clipboard, switch view to plain text mode
I hope it'll help somehow
Bookmarks