Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. Access UI control from another thread

Access UI control from another thread

Scheduled Pinned Locked Moved Mobile and Embedded
4 Posts 3 Posters 8.8k Views 1 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.
  • W Offline
    W Offline
    wizardlee
    wrote on last edited by
    #1

    Environment: QT on S60
    Test application: an UI dialog app. It has only one UI control on the dialog, a text edit. After the dialog displayed, I fork a new thread, derived from QThread. While the thread running, it need append some text to the text edit. So I call QTextEdit::append("123"). Expected result is that "123" is displayed without error. But actual result is, "123" is displayed, but immediately the thread got a panic 3. Debug info shows that the panic happens before return from append(). I know that S60 does not support such updating cross thread. But is it possible in QT for S60? Thanks very much for any reply.

    PS: I have tried disable/enable updating before/after append(), but still panic.

    1 Reply Last reply
    0
    • D Offline
      D Offline
      DenisKormalev
      wrote on last edited by
      #2

      Working with UI from other threads is not a good idea I think. You should better create a slot in main thread and execute it via signal-slot mechanism or invokeMethod() from child thread.

      1 Reply Last reply
      0
      • A Offline
        A Offline
        andre
        wrote on last edited by
        #3

        Indeed.

        Never, ever, touch the UI from outside your UI thread, in any version of Qt. Queued signal/slots (or invoke methods, basically the same) or using custom events posted to the correct event loop are the only save ways to do this.

        1 Reply Last reply
        0
        • W Offline
          W Offline
          wizardlee
          wrote on last edited by
          #4

          Thanks very much. The signal/slot resolve my problem.

          1 Reply Last reply
          0

          • Login

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