PDA

View Full Version : QList question



ln\
18th December 2006, 16:27
Now I'm a java programmer and C programmer buy trade so this could easily be an easy C++ question and I've just not spotted it.

:o

I'd like to creat a list of items in my nice QGraphicsScene and itemise them in a QTreeWidget. Now Qt provides a the ablility to create two forms of QList for each of these entities which is nice.... But without doing the hard work and writing a custom conversion function (after all I am a Java programmer) how would I put the QList<QGraphicsScene *> information into QTreeWidget?

Apologies for my stupidity and thank you for any help you can provide.

James

wysota
18th December 2006, 18:19
I think you meant QList<QGraphicsItem*>...

In such a situation I'd advise using the model approach instead of the convinience class (QTreeView instead of QTreeWidget), but as you're a lazy java programmer I think it will be easier for you to stick with the QTreeWidget approach and implement that conversion after all :) You can subclass QTreeWidgetItem and implement custom functionality for fetching the data from a graphics item there. Something like:

class MyTreeWidgetItem : public QTreeWidgetItem {
public:
MyTreeWidgetItem(const QGraphicsItem *item, QTreeWidgetItem *parentItem){
// ...
}
};

ln\
19th December 2006, 14:01
Your right, I ment QList<QGraphicsItem*>....

Subclasssing QTreeWidgetItem seems a good start for me. I'll give it ago.... but your right again I think in the long term I'll need to use QTreeView. i'm just looking to prototype at the moment and trying to avoid that particular learning curve... there are far too many colons in this C++ language for my liking..... it's ok you can call me picky.

Many thanks!

:D

J