[Qt-interest] parse items of QTreeWidget into file/QSettings
Mystical Groovy
mysticalgr at gmail.com
Sat Nov 7 22:49:03 CET 2009
Oh god Thank you all for your replies again but I dont seem to find a way to
manage this, I can access the model() of QTreeWidget thats for sure, but
then how can i parse the contents of it?(!!)
I'm thinking that maybe its possible if somehow read the rows in QtreeWidget
one by one, and for each row I get the item's text.
Mind if you share some sample code?
many thanks again and sorry for my poor english and if I broke your
nerves... :)
btw in case it helps i forgot to mention that to add the items inside
QTreeWidget I use sample code from Qt docs.
QList<QTreeWidgetItem *> items;
> items.append(new QTreeWidgetItem((QTreeWidget*)0, QStringList(QString("test
> item"))));
> treeWidget->insertTopLevelItems(0, items);
>
2009/11/7 André Somers <andre at familiesomers.nl>
> Just like any other other QAbstractItemView derived class, QTreeWidget
> has a method called “model()” that returns… a QAbstractItemModel. I think it
> could be the model you were after…
>
>
>
> Some tips on iterating over a tree model:
>
> · The root item(s) of your tree have an invalid parent
> QModelIndex, that can be created using the default constructor of that
> class.
>
> · Using rows() you can find out the number of rows (as children of
> a specified parent node)
>
> · Each node in the tree may be the parent of other nodes, but in
> your case, only the nodes in column 0 may be parents of other nodes!
>
> · You can use QAbstractItemModel::index() to create a valid index
> to access the nodes of your model.
>
>
>
> HTH,
>
>
>
> André
>
>
>
>
>
>
>
> *Van:* qt-interest-bounces at trolltech.com [mailto:
> qt-interest-bounces at trolltech.com] *Namens *Mystical Groovy
> *Verzonden:* zaterdag 7 november 2009 17:36
> *Aan:* Arnold Krille
> *CC:* qt-interest at trolltech.com
> *Onderwerp:* Re: [Qt-interest] parse items of QTreeWidget into
> file/QSettings
>
>
>
> Yes maybe you're right I have to read about model/view programming, however
> I dont seem to find out how to access QTreeWidget's model, Im looking at it
> right Ill post if I manage to do anything :P
>
> 2009/11/7 Arnold Krille <arnold at arnoldarts.de>
>
> Hi,
>
>
>
> On Saturday 07 November 2009 16:39:31 Mystical Groovy wrote:
> > Hi and thanks for your reply,
> > I think i got it
> > i wrote on my .h file
> > class MyItemData : public QAbstractItemModel
>
> <snip>
>
> No. I said that you can access the model QTreeWidget is using. Not to
> implement your own...
>
> Sorry to say that but you want to do some serious reading on C++, object-
> oriented programming (look for classes and derivation) and then patterns
> (mostly the Model-View(-Controller)-pattern) and Qt...
>
> Arnold
>
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-interest
>
>
>
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-interest
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20091107/47f99f75/attachment.html
More information about the Qt-interest-old
mailing list