Qt: List of (custom) QWidgets without performance problems

被刻印的时光 ゝ 提交于 2019-12-11 09:53:10

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!