[Qt-interest] QTreeView to QTreeWidget at run-time?
Rob Simmermon
rob.simmermon at simmtechsolutions.com
Wed May 5 17:41:58 CEST 2010
I don't think I'm explaining this well enough. I don't care about the model
at all. I basically want the QListVIew that's in a QTreeView copied to a
QTreeWidget. I need the exact state of the view, not the model. So
whatever is displayed in the view, including column widths, column headings,
column order, etc..., I need copied to a QTreeWidget.
Is this not easily done?
-----Original Message-----
From: Mandeep Sandhu [mailto:mandeepsandhu.chd at gmail.com]
Sent: Wednesday, May 05, 2010 3:07 AM
To: qt-interest at trolltech.com
Subject: Re: [Qt-interest] QTreeView to QTreeWidget at run-time?
>> So my question, that I can't seem to find the answer to after many hours
of
>> searching, is how do I copy all the items and their current states from
the
>> QTreeView to a QTreeWidget, disregarding the model completely.
>>
>> I was looking for some type of default copy constructor that would do
this,
>> but can't find one.
>
> With a model there's no such thing as an "item", at least not as a
> self-contained object. Your model might internally use such items, but
> then you should already know how to get at them...
QStandardItemModel does contain QStandardItem which hold the actual
data. And it also provides a way to get them with either a row/col of
with a model index.
Though the OP did not mention what model is being used in his
app...but as Andreas said you can get the rowCount and columnCount of
your model and extract all data by iterating over it.
HTH,
-mandeep
>
> To transfer some or all of the data in your model you could create a
> loop that runs over all rows+columns and fetches an index for each
> combination, then creates a QTreeWidgetItem and sets the text, icon,
> etc. by using the model's data() function. With a real tree structure
> you'll also want to check wether there are any children and then do the
> same on the child list too.
>
> Andreas
>
> --
> You will probably marry after a very brief courtship.
> _______________________________________________
> 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
More information about the Qt-interest-old
mailing list