I'm testing now QTreeView functionality, and I was amazed by one thing it seems that QTreeView memory consumption items depending O_O it is highly unusual, because the model-view containers such type of tracks to be displayed before, and I rest in item model wrote one of the following codes with a simple model in which there is no data And just reports that 10 The Ladakh items will not have any memory of MFCs with such models, the Windows API or NAT tree / list, because it will request will only 10-20 visible element and item models for more scroll / expansion. But with Qt, ~ 300 MB is the result of such simple models in memory intake. Increasing numbers of items will increase memory consumption. Maybe someone could point me out what I'm doing wrong? :)
#include & lt; QtGui / QApplication & gt; # Include & lt; QTreeView & gt; # Include & lt; QAbstractItemModel & gt; Class CModel: public QAbstractItemModel {public: QModelIndex index (Int i_nRow, int i_nCol, const QModelIndex and i_oParent = QModelIndex ()) const {return createIndex (i_nRow, i_nCol, 0); } Public: QModelIndex Basic (const QModelIndex and i_oInex) const {return QModelIndex (); } Public: int rowCount (Const Kyuemdel Index & amp; i_oParent = QModelIndex ()) const {return i_oParent.isValid ()? 0: 1000 * 1000 * 10; } Public: At Columbus (Consumer Price Index and IOoper = QMDell Index ()) Cost {Return 1; } Public: QVariant data (const QModelIndex and i_oIndex, int i_nRole = Qt :: DisplayRole) const {return Qt :: DisplayRole == i_nRole? QVariant ("1"): QVariant (); }}; Int main (int argc, char * argv []) {Q Application A (argc, argv); QTreeView Ond; CModel oModel; Owond Set Unimanohoites (Truth); OWnd.setModel (& amp; oModel); OWnd.show (); Back a.exec (); } "post-text" itemprop = "text"> If I'm changing the sample source with QTableView the QTreeView, will not consume memory. So it seems that QListView and QTreeView are not intended to be used with very large data and instead QTableView should be used.
Comments
Post a Comment