Results 1 to 6 of 6

Thread: QtableView performances

  1. #1
    Join Date
    Dec 2010
    Posts
    2
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default QtableView performances

    Hi,

    I am using a qtableview with a model to display data, a lot of data
    I implemented the data(const QModelIndex &index, int role) function but it looks like this function is called a lot: (size of each item in Qt::ItemDataRole enum) * number of items in my model which is the way it's apparently set up in Qt.

    but for example if I scroll down to show only one morerow the data function is called again on each item of my model instead of only for the new items in the row I am just showing

    Anyway to cache it or something?

    Thank you

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QtableView performances

    You can cache the value you return from data() if that helps you anything. Qt won't cache it on its own. You can also reimplement itemData() to be somewhat faster than the naive loop over data() calls.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    Aug 2008
    Location
    Nanjing, China
    Posts
    66
    Thanks
    12
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QtableView performances

    "this function is called a lot: (size of each item in Qt::ItemDataRole enum) * number of items in my model which is the way it's apparently set up in Qt."
    Is it true?
    I guess that qt will call the function only if the data is needed to display.
    Jerry

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QtableView performances

    It depends. If you have per-pixel scrolling enabled then Qt has to recalculate item position taking into consideration not only the visible items but also items before it. That's why it helps a lot to set that items have uniform size in the listview. Then only the first item is checked and then result is multiplied by the number of items.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  5. #5
    Join Date
    Dec 2010
    Posts
    2
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QtableView performances

    I already have fixed size policy and scrollperitem enabled actually
    my data function does not compute anything, just call a function that return a precomputed QVariant corresponding to the role on my object at the index in parameter
    Is this problem considered as a bug/issue ?
    I use resizeSection on both of my headers to display as much data as I can but the more I display the more data() is called which is my issue

  6. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QtableView performances

    Quote Originally Posted by bacou View Post
    I already have fixed size policy and scrollperitem enabled actually
    Not fixed size policy but QListView::uniformItemSizes. There is no equivalent of that in QTableView. If you scroll per pixel there, your data will always be queried very often.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Similar Threads

  1. Help with javascript performances on wince
    By lamosca in forum Qt for Embedded and Mobile
    Replies: 0
    Last Post: 4th May 2010, 21:16
  2. help with QtWebkit performances
    By lamosca in forum Qt for Embedded and Mobile
    Replies: 0
    Last Post: 2nd March 2010, 12:47
  3. QWebView 4.6 performances on WinCE devices
    By Diegol in forum Qt for Embedded and Mobile
    Replies: 0
    Last Post: 28th January 2010, 00:06
  4. Replies: 2
    Last Post: 26th November 2009, 04:45
  5. QTableView performances
    By miraks in forum Qt Programming
    Replies: 18
    Last Post: 1st December 2008, 10:25

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.