Results 1 to 20 of 20

Thread: Help with getting my custom model working

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2006
    Location
    travelling
    Posts
    1,116
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    8
    Thanked 127 Times in 121 Posts

    Default Re: Help with getting my custom model working

    Quote Originally Posted by thomaspu View Post
    When I'm calling the insertRows function, I don't know the parent at all. The description in the function reads So If I never have the parent... thats probably why it doesn't work?l
    The point is that you never HAVE any parents anywhere since you're using a table and not a hierarchical (i.e. tree) model. When no parent is involved the parent is the header node which is represented by an invalid parent (which is the default parent passed to all methods that require a parent BTW... )
    Current Qt projects : QCodeEdit, RotiDeCode

  2. #2
    Join Date
    Nov 2006
    Posts
    86
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows
    Thanks
    6
    Thanked 14 Times in 5 Posts

    Default Re: Help with getting my custom model working

    Ok, that makes sense since this is just a flat model. So any ideas why nothing shows up on my QListView after I add an item to my model?

    Paul

  3. #3
    Join Date
    Jan 2006
    Location
    travelling
    Posts
    1,116
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    8
    Thanked 127 Times in 121 Posts

    Default Re: Help with getting my custom model working

    May I ask for the full code?
    Current Qt projects : QCodeEdit, RotiDeCode

  4. #4
    Join Date
    Nov 2006
    Posts
    86
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows
    Thanks
    6
    Thanked 14 Times in 5 Posts

    Default Re: Help with getting my custom model working

    Sure, let me put it together. Just a few min...

  5. #5
    Join Date
    Nov 2006
    Posts
    86
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows
    Thanks
    6
    Thanked 14 Times in 5 Posts

    Default Re: Help with getting my custom model working

    Ok, all you need is attached.

    Paul
    Attached Files Attached Files

  6. #6
    Join Date
    Jan 2006
    Location
    travelling
    Posts
    1,116
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    8
    Thanked 127 Times in 121 Posts

    Default Re: Help with getting my custom model working

    Ok I found the bug... You messed up the rowCount() function... The point in this one is to return the number of connections when the parent passed is the root node (so an invalid index) and to return 0 (no child) when the parent is valid (i.e. one of the connection...)

    Note that before I found that I added a columnCount() function so you may also need to add it so as to have your model working properly...
    Current Qt projects : QCodeEdit, RotiDeCode

  7. The following user says thank you to fullmetalcoder for this useful post:

    thomaspu (29th July 2007)

  8. #7
    Join Date
    Nov 2006
    Posts
    86
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows
    Thanks
    6
    Thanked 14 Times in 5 Posts

    Default Re: Help with getting my custom model working

    Ah, yes, that was it! Yeah, you return the number of connections when the parent is invalid. Which in my case is always cause my list is flat and doesn't have a parent.

    Thanks for all the help, I think I'm good to go for a bit!
    Paul

Similar Threads

  1. hierarchical model in a flat view
    By gniking in forum Qt Programming
    Replies: 4
    Last Post: 10th November 2009, 21:17
  2. Coin3d + Qt: SIGLNALs and SLOTs
    By vonCZ in forum Newbie
    Replies: 26
    Last Post: 15th May 2009, 08:34
  3. Custom Model Class
    By mattjgalloway in forum Qt Programming
    Replies: 12
    Last Post: 4th June 2007, 18:30
  4. Treeview and custom model
    By steg90 in forum Qt Programming
    Replies: 8
    Last Post: 15th May 2007, 14:54
  5. TreeView custom model
    By steg90 in forum Newbie
    Replies: 1
    Last Post: 9th May 2007, 11:06

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.