问题
I'm right now creating an Qt-application and have following problem: I designed a custom QWidget with some labels and checkboxes. The application should now show a list of the custom QWidgets. I tried the QListWidget but is very slow for my use case. I want to add over 6000 elements of my custom QWidget. If I create these instances of the element and add it to the QListWidget the application will crashed.
Which is the best approach for my issue?
Thanks a lot!
回答1:
As others have noted, QListWidget
or QListView
is the way to go. Also note that you should not display custom widgets with it, try using a custom QStyledItemDelegate instead and draw the items yourself. Depending on what you need, this can get complex really fast. I have used QTableView
with this approach with tenth of thousands of items without performance problems.
If you really need to display custom widgets, check out a library I wrote some time ago for that exact purpose: longscroll-qt .
来源:https://stackoverflow.com/questions/48290188/qt-list-of-custom-qwidgets-without-performance-problems