Results 1 to 10 of 10

Thread: different model element, different delegate in a list view

  1. #1
    Join Date
    Feb 2011
    Posts
    11
    Thanked 1 Time in 1 Post
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows Symbian S60

    Default different model element, different delegate in a list view

    Hi everyone:

    i would like create a listview (qml), where each element is not the same. Plus, the way to display each element (delegate) is not the same either.

    is there anyone who have encounted this kind of problem?

    thanks

  2. #2
    Join Date
    Jan 2011
    Posts
    18
    Thanks
    6
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: different model element, different delegate in a list view

    Hi,
    Even i have the same problem , checking for a solution . Hope someone would help us find a solution.

  3. #3
    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: different model element, different delegate in a list view

    What do you mean by "not the same"?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  4. #4
    Join Date
    Feb 2011
    Posts
    11
    Thanked 1 Time in 1 Post
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows Symbian S60

    Default Re: different model element, different delegate in a list view

    Quote Originally Posted by chetu1984 View Post
    Hi,
    Even i have the same problem , checking for a solution . Hope someone would help us find a solution.
    hi
    I have found the solution. you can use visualistmodel instead of listmodel.

  5. The following user says thank you to huluyige for this useful post:

    chetu1984 (18th February 2011)

  6. #5
    Join Date
    Feb 2011
    Posts
    11
    Thanked 1 Time in 1 Post
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows Symbian S60

    Default Re: different model element, different delegate in a list view

    Quote Originally Posted by wysota View Post
    What do you mean by "not the same"?
    thanks for your reply,

    for instance, if i use listmodel, but for each element, roles are not the same. how can i do it

  7. #6
    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: different model element, different delegate in a list view

    Roles are always the same. Their values might not be. If roles are different then you have two separate models. You can declare the delegate in such a way that it takes values into consideration.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  8. #7
    Join Date
    Feb 2011
    Posts
    11
    Thanked 1 Time in 1 Post
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows Symbian S60

    Default Re: different model element, different delegate in a list view

    Quote Originally Posted by wysota View Post
    Roles are always the same. Their values might not be. If roles are different then you have two separate models. You can declare the delegate in such a way that it takes values into consideration.
    yes, that's the problem. if roles are not the same, what should i do? i think i can't use listmodel anymore.

  9. #8
    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: different model element, different delegate in a list view

    I really don't see your point. A model has to be consistent. Keeping "apples" and "cars" in a single model doesn't make any sense if they don't have anything in common. If they do (e.g. they are "objects") then they have the same roles (i.e. "object name", "object type", etc.). Then you can say if "object type" is "car", display it like this, otherwise display it like that.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  10. #9
    Join Date
    May 2010
    Posts
    61
    Thanks
    2
    Thanked 6 Times in 5 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: different model element, different delegate in a list view

    Hi wysota,

    You said
    if "object type" is "car", display it like this, otherwise display it like that.
    .
    How exactly can you embed this "if" condition into the delegate?

    Thanks in advance,
    Wladek
    One second is long, everything longer than two seconds is definitely too long.

  11. #10
    Join Date
    Feb 2011
    Posts
    11
    Thanked 1 Time in 1 Post
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows Symbian S60

    Default Re: different model element, different delegate in a list view

    Quote Originally Posted by wladek View Post
    Hi wysota,

    You said.
    How exactly can you embed this "if" condition into the delegate?

    Thanks in advance,
    Wladek
    you can use ? :

Similar Threads

  1. Model-View-Delegate
    By hotdox in forum Qt Programming
    Replies: 3
    Last Post: 11th May 2010, 13:20
  2. Replies: 8
    Last Post: 6th May 2010, 11:17
  3. How to map tree model data to list view
    By msopanen in forum Qt Programming
    Replies: 0
    Last Post: 10th November 2009, 19:56
  4. Model View - Delegate - setIndexWidget
    By starcontrol in forum Qt Programming
    Replies: 16
    Last Post: 2nd April 2008, 14:30
  5. [QT4.1.1 XP] multi-columns list model/view
    By incapacitant in forum Newbie
    Replies: 1
    Last Post: 26th February 2006, 13:38

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.