Results 1 to 5 of 5

Thread: [QTableWidget] clearing a big table takes so long!

  1. #1
    Join Date
    Oct 2007
    Posts
    22
    Thanks
    3
    Qt products
    Qt4
    Platforms
    Windows

    Angry [QTableWidget] clearing a big table takes so long!

    Hello,

    I have a QTableWidget which owns 640*480 QTableWidgetItems.
    When I make a clearContents() on it, it takes several seconds to do it. Is there any way to empty the table faster?

    Thank you.

  2. #2
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: [QTableWidget] clearing a big table takes so long!

    640*480 are 307200 items! You really should consider using a model. And there is no faster way, only create a new table widget and remove the items in background.

  3. The following user says thank you to Lykurg for this useful post:

    punkypogo (5th August 2010)

  4. #3
    Join Date
    Oct 2007
    Posts
    22
    Thanks
    3
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: [QTableWidget] clearing a big table takes so long!

    I know this is really huge. Do you think using a model will increase performance?

  5. #4
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: [QTableWidget] clearing a big table takes so long!

    Well, a QStandardItemModel surely not, but if use e.g. a SQL** model (or a custom one) then yes, because no items (=disk memory) need to be removed etc. Just set up a database with 30.000.000 items and display them using a QSqlTableModel and see how fast it is "cleared".

  6. #5
    Join Date
    Oct 2007
    Posts
    22
    Thanks
    3
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: [QTableWidget] clearing a big table takes so long!

    I just implemented with QAbstractTableModel, and wow! This is incredibly fast compared to QTableWidget!

    Thanks a lot for your answer!
    Cheers.

Similar Threads

  1. QTextEdit loading takes long time
    By sreedhar in forum Qt Programming
    Replies: 12
    Last Post: 21st March 2011, 10:29
  2. Replies: 3
    Last Post: 17th March 2010, 10:31
  3. Long text inside a table cell
    By TheKing in forum Qwt
    Replies: 0
    Last Post: 15th December 2009, 20:35
  4. QImage::scaled takes long time
    By nrabara in forum Qt Programming
    Replies: 0
    Last Post: 15th December 2009, 12:19
  5. Layout long text in QTableWidget
    By Tamtam in forum Newbie
    Replies: 0
    Last Post: 13th February 2009, 15:09

Tags for this Thread

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.