frmdstryr / enamlx

Additional Qt Widgets for Enaml
MIT License
28 stars 9 forks source link

Table view is lagging #10

Open zenchanhk opened 6 years ago

zenchanhk commented 6 years ago

Hi,

I tried TableView and found it quite lagging when scrolling, when the number of row decreased to 100, it becomes smooth. Is there any way to improve it? My environment: Python: 3.6.5 Windows: 10 home edition CPU: i7-6500U Memory: 8G

By the way, is it possible to customize the table header and be sortable? Thanks a lot!

frmdstryr commented 6 years ago

Only create rows for the number of rows that can be seen at one time on the screen. If you're viewing a dataset with 1M rows but the screen only fits 50 rows when maximized, the Looper should create only 50 rows (plus a few extra to be safe, I usually just set it to 100). If that's what you're doing and it's still slow then you can create your own table using a RawWidget.

Only titles are currently exposed, for more control you can customize the table header by modifying the proxy widget directly (ex `widget = table.proxy.widget). See https://doc.qt.io/qt-5/qtableview.html for the widget's methods and members. You can add sorting by connecting a callback to sortIndicatorChanged of the https://doc.qt.io/qt-5/qheaderview.html.

I want to redesign TableView to use a recycling pattern as the current method inefficiently updates every visible node when scrolling vs only updating the ones that come on or go offscreen. It currently uses more CPU than it should.

zenchanhk commented 6 years ago

Thanks for your detailed explanation. I've tried the example and set the number of visible rows, but seems still lagging. I've created my own table using ProxyControl/Control, and it worked well with 75k rows. But have no idea how to update the table like you've done in your example without sending a signal to update the table? Thanks again.