Results 1 to 3 of 3

Thread: QList question

  1. #1
    Join Date
    Dec 2006
    Posts
    2
    Thanks
    1
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default QList question

    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.



    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
    Last edited by wysota; 18th December 2006 at 17:13. Reason: reformatted to look better

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QList question

    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:
    Qt Code:
    1. class MyTreeWidgetItem : public QTreeWidgetItem {
    2. public:
    3. MyTreeWidgetItem(const QGraphicsItem *item, QTreeWidgetItem *parentItem){
    4. // ...
    5. }
    6. };
    To copy to clipboard, switch view to plain text mode 

  3. The following user says thank you to wysota for this useful post:

    ln\ (19th December 2006)

  4. #3
    Join Date
    Dec 2006
    Posts
    2
    Thanks
    1
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QList question

    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!



    J

Similar Threads

  1. Query about QHash , QList
    By aamer4yu in forum Qt Programming
    Replies: 3
    Last Post: 14th December 2006, 09:04
  2. QList crash in destructor
    By mclark in forum Newbie
    Replies: 7
    Last Post: 6th December 2006, 15:27
  3. Accessing QList Objects
    By magikalpnoi in forum Qt Programming
    Replies: 7
    Last Post: 21st September 2006, 20:43
  4. QTableView paints too much
    By Jimmy2775 in forum Qt Programming
    Replies: 2
    Last Post: 26th July 2006, 18:42
  5. Values not being appended in a QList
    By Kapil in forum Newbie
    Replies: 5
    Last Post: 21st April 2006, 10:20

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.