Results 1 to 4 of 4

Thread: Model-view: Display items in different ways

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #2
    Join Date
    Feb 2007
    Posts
    24
    Thanks
    3
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Model-view: Display items in different ways

    Quote Originally Posted by taboom View Post
    [/code]Is this how this is "supposed" to be done, or should the roles instead be directly used, so that drawing draws something only if the node is of correct type?
    Qt Code:
    1. //We have several ItemDataRoles defined
    2. int TypeARole = 34;
    3. int TypeBRole = 35;
    4.  
    5. drawNode( child.data( TypeARole ) ); //Draws a rectangle, but only for A-type nodes
    6. drawNode( child.data( TypeBRole ) ); //Draws a circle but only for B-type nodes
    To copy to clipboard, switch view to plain text mode 
    Or are there other better alternatives?
    I'm guessing that this last piece of code is part of a custom view and not somehow part of the model...

    I think your on the right track with your primary description of discriminating in the data() method. The only minor thing I do differently is contain the "type" in my item node instead of a custom role. Just a personal preference.

    Mind you, I'm not an expert yet though. -travlr
    Last edited by travlr; 12th August 2007 at 15:43.

Similar Threads

  1. hierarchical model in a flat view
    By gniking in forum Qt Programming
    Replies: 4
    Last Post: 10th November 2009, 20:17
  2. Graphics view display problem.
    By kiranraj in forum Qt Programming
    Replies: 3
    Last Post: 20th July 2007, 07:08
  3. Model, View and Proxy
    By No-Nonsense in forum Qt Programming
    Replies: 2
    Last Post: 21st November 2006, 08:50
  4. Model - View Programming doubt.
    By munna in forum Qt Programming
    Replies: 4
    Last Post: 28th April 2006, 13:01
  5. Replies: 6
    Last Post: 20th April 2006, 10:23

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.