Save QTreeWidget to file



  • Does there any functions (classes) in QT for saving QTreeWidget object with content into file?

    Problem:
    I have content of tree in external XML file (6Mbytes – passes into process by parameter of command line). Transformation of this file to tree takes more than 1 min on my computer. It is not acceptable for users. Main problem (time consumpion) is not in processing XML file, but in construction of tree. Each second item of tree has 10 columns.

    Idea:
    Save QTreeWidget into file (like in Java) and read it from this one.

    Has anybody any advance please ?


  • Moderators

    AFAIK, it's not possible out-of-the-box to stream the QTreeWidget.

    As a productive workaround, consider using raw QTreeView, an fine tune the performance there. It will take a lot of time to code, but then you have full control over creation of the tree, and can optimise. You can also take a look at QTreeView::setUniformRowHeights() (I think QTreeWidget has this method, too). If applicable, it can improve performance not only during tree population, but also during normal usage.



  • I don't think that (de)serializing your in-memory data will improve your performance, as obviously creating this in-memory data is your bottleneck (which has to be done either way).

    Take a look at the "Simple DOM Model Example":http://qt-project.org/doc/qt-4.8/itemviews-simpledommodel.html, which explains how to use an XML file (or more specifically a QDomDocument) as an item model (which then can be used with QTreeView).



  • Thank you, Iĺl try it


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.