Results 1 to 8 of 8

Thread: QTreeWidget and Graphics scene

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,371
    Thanks
    3
    Thanked 5,019 Times in 4,795 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QTreeWidget and Graphics scene

    Quote Originally Posted by aamer4yu View Post
    I tried to read about models, and right now its going over my head.
    It's better to switch to the model approach sooner than later, you'll have less rewriting to do

    For the beginning you can cheat a little, use QStandardItemModel and either create a custom item role which will hold a pointer to a graphicsview item or reimplement the index() method of the model and store the pointer as the internal pointer. The latter solution is better, but it'll only work if QStandardItemModel doesn't use that internal field for itself.

    Also I need a tree with single column, so I am not sure to go in for a model for this... there must be a simple way
    The point is that you don't want to do simple things, so you shouldn't use simple solutions.

    I cud have used this approach, but not all treeWidgetItems are related to GraphicsItem, like the PL.. it contains a list of graphicsitems which are contained in it.
    Does it matter? You only store there what you like.

    Also in future I may need to add tree nodes based on certain lists and not graphicsitems..
    That's another argument for using a full featured model.

    Also I would be glad if u teach me something about the model , model/view architecture in context with this prpblem, I searched thru Qt Examples but cudnt find a suitable example related to my problem.. only if experts like u speak something, it wud be a great speed up for guys like me
    When I find some tme (during Christmas maybe?) I'll post an example model made from scratch on my website (in the GL model article series), so you'll be able to take a look.

  2. #2
    Join Date
    Oct 2006
    Location
    New Delhi, India
    Posts
    2,467
    Thanks
    8
    Thanked 334 Times in 317 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Question Re: QTreeWidget and Graphics scene

    Thanks for the reply...
    Currently I am making a prototype of an application which I have to make later on.. and need to finish it soon....
    so I guess implementing the model will take time and i wont be able to meet the deadlines in meantime I have to stick to some shortcuts
    I can explore optimising things later for the main project....

    When I find some tme (during Christmas maybe?) I'll post an example model made from scratch on my website (in the GL model article series), so you'll be able to take a look.
    I will be waiting for it eagerly...
    Thanx again

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

    Default Re: QTreeWidget and Graphics scene

    Quote Originally Posted by aamer4yu View Post
    Currently I am making a prototype of an application which I have to make later on.. and need to finish it soon....
    It takes not more than an hour to implement a simple model.
    so I guess implementing the model will take time and i wont be able to meet the deadlines in meantime I have to stick to some shortcuts
    Sure, just make sure the shortcuts are really shorter than the full-featured solution

  4. #4
    Join Date
    Oct 2006
    Location
    New Delhi, India
    Posts
    2,467
    Thanks
    8
    Thanked 334 Times in 317 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QTreeWidget and Graphics scene

    It takes not more than an hour to implement a simple model.
    an hour for you ?? i wonder how long it will take for me..

    jokes apart,,, i will try if u say so... can u give some steps regarding the same..
    and yeah, I will be waiting for ur example
    Thx

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

    Default Re: QTreeWidget and Graphics scene

    Quote Originally Posted by aamer4yu View Post
    an hour for you ?? i wonder how long it will take for me..
    You can start by modifying the simple tree model example. It'll take you 10 minutes then

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
  •  
Qt is a trademark of The Qt Company.