Hello !
I subclassed QItemDelegate, QAbstractItemModel in order to build tree model and see data in QTreeView. Now I need to modify model data, do I have to subclass QTreeView or I can achive it using QTreeView ?
Hello !
I subclassed QItemDelegate, QAbstractItemModel in order to build tree model and see data in QTreeView. Now I need to modify model data, do I have to subclass QTreeView or I can achive it using QTreeView ?
Best regards,
Yuriy Rusinov.
I tested to subclass the item :-( is not easy!
I found a way to make a xml file tree unlimited .... and on a simple class i manage
the domelement & QTreeWidgetItem & the level of tree....
each new Item i add on aa QList<OneTree*> niagaratree; xxx.additem(**) an so i can interact on 2 class... on add item remove rename ecc... on QDomElement you can save all data image html page e other ..on.. QDomElement like a oracle DB :-)....
to delete on item i save the Nr of tree ... and fast save the file xml + reload the GUI whitout the delete nr..item ...
Is moore simple way... and fast....
Qt Code:
QList<OneTree*> niagaratree; typedef QMap<QString, QString> Treevar; class QTreeWidget; class QTreeWidgetItem; { Q_OBJECT public: ............... private: ..... signals: void SendtonewDom(int); public slots: void MoveToNewDest() { /////qDebug() << "### ONLISTER emit start " << ONLISTER; emit SendtonewDom(ONLISTER); } };To copy to clipboard, switch view to plain text mode
Last edited by patrik08; 26th October 2006 at 12:51.
That I have to make view classes, which inherits QTreeView ?
Best regards,
Yuriy Rusinov.
OK, I'll process signal clicked() on QTreeView and make editor events. Thanks.
Best regards,
Yuriy Rusinov.
If You like grab the first structure from Tree Category
http://ppk.ciz.ch/win_build/tree_cat_memo/Tree_Cat.zip
& + the idea of class OneTree you can associate 100 of attribute each single node....
to test right click and insert node sets...
this sample code replace on old Nested Sets mysql from an old cms Category manager... same as ....
http://www.klempert.de/nested_sets/demo/
YuriyRusinov (26th October 2006)
You can achieve it with QTreeView. The view is just for displaying data and you want to change the data itself - the model. Editing model data is a responsibility of item delegate - it calls setData() on the model where appropriate, just make sure your model can handle setData() calls. If you take a look at QItemDelegate - there are createEditor, setEditorData and setModelData methods. They are responsible for edition. You can reimplement them if the default implementations don't suit your needs (but maybe they do, check that out). Just make sure data in your model is editable (return ItemIsEditable if flags() for each index you want editable) and set proper triggers in the view using QAbstractItemView::setEditTriggers().
YuriyRusinov (27th October 2006)
Bookmarks