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. Refreshing content of QTableWidget
Forum Updated to NodeBB v4.3 + New Features

Refreshing content of QTableWidget

Scheduled Pinned Locked Moved Solved General and Desktop
5 Posts 3 Posters 10.8k 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.
  • P Offline
    P Offline
    PetQter
    wrote on last edited by
    #1

    Hello,
    I have subclass of QDialog with QTableWidget. This dialog is modeless and it is in dock. I need to refresh content of QTableWidget when this dialog is not focused and user works with other dock. Table is refreshed only when get focus by user click, or when I minimalize/maximalize application window.

    I tried to call from inside of dialog member function
    item->setData() ;
    update()/repaint(); - not working.
    ui->myTableWidget->update()/repain(); - not working.
    ui->myTableWidget->viewport()->update(); - it works !

    I read documentation and looked through forums and every wrote that update()/repaint() should refresh content.
    So I have doubt that ui->myTableWidget->viewport()->update(); is correct way or is it ?

    1 Reply Last reply
    0
    • mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi
      For a QTableWidget/view the viewport is the class drawing the visible items.
      But it sounds very odd you manually have to call update() on it.
      Normally that is never needed.

      By not updating, you mean you from outside inserts new items and they are not showing before
      user click on Table?

      P 1 Reply Last reply
      1
      • mrjjM mrjj

        Hi
        For a QTableWidget/view the viewport is the class drawing the visible items.
        But it sounds very odd you manually have to call update() on it.
        Normally that is never needed.

        By not updating, you mean you from outside inserts new items and they are not showing before
        user click on Table?

        P Offline
        P Offline
        PetQter
        wrote on last edited by
        #3

        @mrjj Yes, parent dialog has public member function and it calls setText() on some cells of child QTableWidget. When QTableWidget get focus then it redraws content of all cells. (without calling ui->myTableWidget->viewport()->update())

        Can be problem that setText() is called from subclass of QThread and not from main application thread ?

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          Hi,

          Don't call GUI objects method from other threads. If you want to modify some text from another thread then use signals and slots.

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

          P 1 Reply Last reply
          4
          • SGaistS SGaist

            Hi,

            Don't call GUI objects method from other threads. If you want to modify some text from another thread then use signals and slots.

            P Offline
            P Offline
            PetQter
            wrote on last edited by
            #5

            @SGaist Thank you, problem solved.

            1 Reply Last reply
            1

            • Login

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