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 update QTableWidget in non-mainThread?
Forum Update on Monday, May 27th 2025

how to update QTableWidget in non-mainThread?

Scheduled Pinned Locked Moved Unsolved General and Desktop
5 Posts 3 Posters 776 Views
  • 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.
  • O Offline
    O Offline
    opengpu
    wrote on last edited by
    #1

    how to update QTableWidget in non-mainThread(ie. a callback function in the other thread).
    QTableWidget need to update(many items should setText) use the data got in that callback fun in the other thread.
    thank you!

    aha_1980A 1 Reply Last reply
    0
    • O opengpu

      how to update QTableWidget in non-mainThread(ie. a callback function in the other thread).
      QTableWidget need to update(many items should setText) use the data got in that callback fun in the other thread.
      thank you!

      aha_1980A Offline
      aha_1980A Offline
      aha_1980
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @opengpu

      You should really read https://doc.qt.io/qt-5/signalsandslots.html

      This is essential for a Qt programmer and will help you to synchronize threads.

      Apropos threads: That is advanced stuff and will require a deep understanding. I recommend starting with something simpler.

      Qt has to stay free or it will die.

      1 Reply Last reply
      4
      • O Offline
        O Offline
        opengpu
        wrote on last edited by
        #3

        thanks, i know it.
        so i just set the 5th param of connect by default value? and the sender & reciever are in different threads?

        jsulmJ 1 Reply Last reply
        0
        • O opengpu

          thanks, i know it.
          so i just set the 5th param of connect by default value? and the sender & reciever are in different threads?

          jsulmJ Offline
          jsulmJ Offline
          jsulm
          Lifetime Qt Champion
          wrote on last edited by
          #4

          @opengpu For signals/slots across different threads use Qt::QueedConnection as connection type. Usually Qt will recognise that sender and receiver are in different threads and use the queued connection, but to be on the safe side you can specify the connection type explicitly.
          One very important rule: NEVER change UI related stuff from other thread than main thread!
          So, emit a signal from the other thread and update your UI in the main thread (in the slot).

          https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          3
          • O Offline
            O Offline
            opengpu
            wrote on last edited by
            #5

            ok, got it. thanks!

            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