Results 1 to 1 of 1

Thread: QTableWidget not updating

  1. #1
    Join Date
    Feb 2021
    Posts
    3
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: QTableWidget not updating

    I have a QTableWidget that is loaded with file info from QDir loop. I also have a QFileSystemWatcher that will call an update function if one of the files changes. It basically just reads the file info again and updates the rows. I've run into a weird issue where if I update one of the files manually in explorer the code to update the table is called from the watcher but the display doesn't actually update. However if I call the exact same function from a button it updates instantly.

    I'm updating the info using calls like this....

    QTableWidgetItem *pStatusItem = ui.fileList->item(row, 0);
    pStatusItem->setText(sStatus);

    I've tried adding ui.fileList.update() and ui.fileList.repaint() after the update, but neither works.

    Another oddity is if I add a breakpoint to the code then as soon as I release the break it updates. But without the break it doesn't update.

    Does anyone have any idea what's causing this?

    I'm using widgets 5.15.2


    Added after 7 minutes:


    OK, never mind. Turns out this is some sort of timing issue. The watch event is being called so quickly that the file isn't ready to be opened so that's failing to get the info to update the list. It's working from the button and with the breakpoint because that little delay between editing the file and triggering those is enough to free up the file.
    Last edited by Dan203; 11th February 2021 at 03:02.

Similar Threads

  1. Replies: 2
    Last Post: 1st June 2017, 23:53
  2. Selection Qtablewidget inside qtablewidget
    By chistof in forum Qt Programming
    Replies: 0
    Last Post: 4th July 2016, 17:24
  3. Replies: 3
    Last Post: 11th August 2015, 00:26
  4. Replies: 1
    Last Post: 6th January 2011, 05:19
  5. Updating a QTableWidget through a Dialog
    By dragon in forum Newbie
    Replies: 3
    Last Post: 19th January 2006, 22:16

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.