Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How to use postEvent for QTextBrowser::setText?
Forum Updated to NodeBB v4.3 + New Features

How to use postEvent for QTextBrowser::setText?

Scheduled Pinned Locked Moved General and Desktop
qeventqthreadposteventsettext
2 Posts 2 Posters 1.3k Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    asmirn
    wrote on 25 Sept 2015, 08:46 last edited by asmirn
    #1

    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?

    1 Reply Last reply
    0
    • S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 25 Sept 2015, 22:46 last edited by
      #2

      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.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      1

      1/2

      25 Sept 2015, 08:46

      • Login

      • Login or register to search.
      1 out of 2
      • First post
        1/2
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved