Results 1 to 10 of 10

Thread: QTableView - scroll performance changed from 4.0 to 4.1 and 4.2

  1. #1
    Join Date
    Nov 2006
    Posts
    9
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default QTableView - scroll performance changed from 4.0 to 4.1 and 4.2

    Hi all,
    i need to move my code from 4.0 to 4.2. But unfortunately found big problem in performance when scrolling in QTableView with many custom widgets loaded in the table and in "Edit Mode". One can easily reproduce this phenomena with use of QT4 example - SpinBoxDelegate under Item View examples. Just modify main.cpp from:

    Qt Code:
    1. QStandardItemModel model(4, 2);
    2.  
    3. for (int row = 0; row < 4; ++row)
    4. {
    5. for (int column = 0; column < 2; ++column)
    6. {
    7. QModelIndex index = model.index(row, column, QModelIndex());
    8. model.setData(index, QVariant((row+1) * (column+1)));
    9. }
    10. }
    To copy to clipboard, switch view to plain text mode 

    to

    Qt Code:
    1. QStandardItemModel model(400, 200);
    2.  
    3. for (int row = 0; row < 400; ++row)
    4. {
    5. for (int column = 0; column < 200; ++column)
    6. {
    7. QModelIndex index = model.index(row, column, QModelIndex());
    8. model.setData(index, QVariant((row+1) * (column+1)));
    9. tableView.openPersistenEditor(index);
    10. }
    11. }
    To copy to clipboard, switch view to plain text mode 

    I know it takes so looong time to load all the widgets to the table, but this is not big issue for me, because it starts only once.
    Anyway there had to be a significant change in QT from 4.0. Because with 4.0 the same code had no problem with sroll at all.

    Any ideas? Did i miss something?

    Thanks a lot!
    B.

  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 - scroll performance changed from 4.0 to 4.1 and 4.2

    I'd say it's a misdesign on your side. Do you really need 80000 editors open at the same time? You won't modify all the items at once, will you? I modified your code, as I'm not patient enough to wait an hour before the application starts up, so that it only opened 5000 editors and it still behaved awfully. Each time I scrolled something, all the widgets needed to be repositioned - first they disappeared from the view and then I turned off the application before they had a chance to show up again (again, I'm not patient enough). You should really reconsider changing your design. The easiest way would be to only use editors for a single row and for all the other rows just paint the same set of controls a spinbox has so that it can mimic its look. I'm sure it'll get a looooooot faster this way.

  3. #3
    Join Date
    Nov 2006
    Posts
    9
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QTableView - scroll performance changed from 4.0 to 4.1 and 4.2

    Yes, you are surely right. Actualy i'm using 20x10 widgets, just to fill screen. Then i'm reusing them somehow. Simply i needed to have all widgets ready for edit and they are more complicated in real. Imagine some stock monitoring application with progress bars and custom designed widgets to edit and monitor courses. Probably "not focuesd ones" i should just paint. But anyway i have to solve my transfer to 4.2 from 4.0. And in 4.0 scroll was not a problem at all. So what changed here in the meantime? Is there another way out than change in design? Of course, to stay with 4.0 is not the answer.
    Thanks again!
    B.

  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 - scroll performance changed from 4.0 to 4.1 and 4.2

    Probably something was optimised or fixed, but as you are using the framework in a very... emmm... uncommon way the probably that optimisation turned out to be a slowdown for you or you might have been benefiting from a bug and when the bug was fixed the benefit vanished.

    Maybe you should use a QScrollArea filled with widgets instead of a table view?

  5. #5
    Join Date
    Nov 2006
    Posts
    9
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QTableView - scroll performance changed from 4.0 to 4.1 and 4.2

    Please, tell me how one can easily paint widget which contains 3-4 other widgets to item in TableView. Simply i need these features of TableView as resizing columns, hiding columns. That's why i'm using table.

    Attached is the picture of what i've got and need. How this can be done more optimized way?
    Thanks a lot!
    B.
    Attached Images Attached Images

  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 - scroll performance changed from 4.0 to 4.1 and 4.2

    Quote Originally Posted by budul View Post
    Please, tell me how one can easily paint widget which contains 3-4 other widgets to item in TableView.
    Create a custom widget with the other widgets inside it (in a layout) and then use QAbstractItemView::setIndexWidget() to set the widget. If you need the widget to be able to edit the data inside the model then set it as an editor instead.

  7. #7
    Join Date
    Nov 2006
    Posts
    9
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QTableView - scroll performance changed from 4.0 to 4.1 and 4.2

    That's exactly what i'm doing, but via delegate. But my problem is that even if i set 20x10 widgets to the table i've got very poor performance. How can i create table with 20x10 custom widgets and will have good response from the GUI in 4.2?

    I really can't have just text in the cells. :-(

    Thanks again.
    B.

  8. #8
    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 - scroll performance changed from 4.0 to 4.1 and 4.2

    Each subsequent permanent editor takes longer to add to the view, so you might want to avoid those. Using index widgets should be faster as they are not updated by the view.

    In your case maybe it would be best to get rid of the view and just emulate the columns by using a QHeaderView and a custom layout (you would probably need to implement an own grid layout, but it shouldn't be too hard).

  9. #9
    Join Date
    Nov 2006
    Posts
    9
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QTableView - scroll performance changed from 4.0 to 4.1 and 4.2

    Solution which works much better with 4.2 is to leave QTableWidget as Wysota advised. So QHeaderView + QGridLayout in QScrollArea works fine for horizonatl scrolling now. It is different with resizing columns (as table does) and hiding columns. It's not so fast as before and as one can see with use of QSplitter, but it's not big deal for me. Thanks anyway.

  10. #10
    Join Date
    Oct 2006
    Location
    Poznan, Poland
    Posts
    14
    Thanked 1 Time in 1 Post
    Qt products
    Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QTableView - scroll performance changed from 4.0 to 4.1 and 4.2

    Quote Originally Posted by budul View Post

    Qt Code:
    1. QStandardItemModel model(400, 200);
    2.  
    3. for (int row = 0; row < 400; ++row)
    4. {
    5. for (int column = 0; column < 200; ++column)
    6. {
    7. QModelIndex index = model.index(row, column, QModelIndex());
    8. model.setData(index, QVariant((row+1) * (column+1)));
    9. tableView.openPersistenEditor(index);
    10. }
    11. }
    To copy to clipboard, switch view to plain text mode 
    I'm thinking, that not all ist ok with setData. First parameter of this function is so called role. User should use as first index of data the Qt+UserRole (+0, +1, +2, ... ).

    piotr

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.