Results 1 to 3 of 3

Thread: QListView and big database - bad performance

  1. #1
    Join Date
    Jan 2014
    Posts
    76
    Thanks
    17
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default QListView and big database - bad performance

    Hi,
    I have problem with performance QListView.

    For add items I used this function

    Qt Code:
    1. void MainWindow::addToModel(const QString &path)
    2. {
    3. QStandardItem * item = new QStandardItem();
    4. item->setIcon( icon );
    5. item->setText( path );
    6.  
    7. dirModel.appendRow( item ); // QStandardItemModel
    8.  
    9. }
    To copy to clipboard, switch view to plain text mode 

    It work fine but when I try add 200 000 items my application froze for 3-4 seconds.

    What I already done is

    Qt Code:
    1. setUniformItemSizes( true );
    To copy to clipboard, switch view to plain text mode 

    What can I do to speed up this process?
    Last edited by atomic; 26th July 2014 at 18:56.

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: QListView and big database - bad performance

    Maybe use QFileSystemModel?

    Cheers,
    _

  3. #3
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,230
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: QListView and big database - bad performance

    Besides the fact that no one is going to look at a list view containing 200,000 items (Do you seriously think any user will do that? Would you?), the way you are appending to the model probably is causing (1) the model to resize itself frequently and (2) the list view to redraw itself (and maybe sort) with each new entry.

    If you know in advance how many things you are adding, then set the rowCount() on the model first, then use setItem() instead of appendRow().

    You could also create all of the QStandardItem instances, put them in a QList<> and add them all at once with insertColumn() or appendColumn(). Remember that with a QListView, you only get one column.

  4. The following user says thank you to d_stranz for this useful post:

    atomic (29th July 2014)

Similar Threads

  1. QListView performance issue
    By zgulser in forum Qt Programming
    Replies: 7
    Last Post: 4th June 2014, 09:39
  2. Replies: 2
    Last Post: 6th April 2014, 12:07
  3. oracle Database performance in QT
    By gbaguma in forum Qt Programming
    Replies: 2
    Last Post: 3rd August 2013, 02:23
  4. How to show images from database as icons in QListView
    By LeshaS in forum Qt Programming
    Replies: 2
    Last Post: 21st January 2011, 08:13
  5. QListView and DataBase
    By ederbs in forum Qt Programming
    Replies: 2
    Last Post: 28th October 2006, 16:18

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.