How to use postEvent for QTextBrowser::setText?



  • I use my class derived from QThread and I get error

    Cannot send events to objects owned by a different thread.

    When

     ui->textBrowser->setText(str);
    

    I read that postEvent can solve my problem so I want to try to use

    QApplication::instance()->postEvent(ui->textBrowser, &ev, INT_MAX);
    

    If this can solve my problem which class I have to use for ev and how to set it?


  • Lifetime Qt Champion

    Hi,

    You can modify GUI elements from other threads. You should rather use signals and slots to communicate between both. It will handle the communication properly for you.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.