Results 1 to 16 of 16

Thread: How to implement nested editable lists in C++ as models in Qt (QML oriented)

Hybrid View

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

    Default Re: How to implement nested editable lists in C++ as models in Qt (QML oriented)

    Quote Originally Posted by ribtoks View Post
    Ok, I tried to implement it as QAbstractListModel,
    Why not QAbstractItemModel?
    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.


  2. #2
    Join Date
    Nov 2014
    Posts
    20
    Qt products
    Qt5
    Platforms
    MacOS X Unix/X11
    Thanks
    1

    Default Re: How to implement nested editable lists in C++ as models in Qt (QML oriented)

    Quote Originally Posted by wysota View Post
    Because it looked easier (I hadn't idea why I need QAbstractItemModel). I had class for List of Lists which was QAbstractListModel and child List which also was QAbstractListModel (which I planned to return as a property through parent's data() method).
    Why this is bad? (or why this was bad? I'm going to rewrite it based on responses in this thread)

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

    Default Re: How to implement nested editable lists in C++ as models in Qt (QML oriented)

    You want a hierarchical model thus it seems to me implementing a proper model will do the job. I don't think returning a list in each model which will in turn return a list of its own is a better approach.
    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
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts

    Default Re: How to implement nested editable lists in C++ as models in Qt (QML oriented)

    Quote Originally Posted by wysota View Post
    Easier to implement a list with QAbstractListModel at its base.
    QAbstractItemModel requires implementations for columnCount(), index() and parent(), the latter two usually not trivial, and neither is needed for a list.

    Quote Originally Posted by wysota View Post
    You want a hierarchical model thus it seems to me implementing a proper model will do the job.
    Aside from ribtoks data not being hierachical as it turns out, I don't think QtQuick can deal with tree models at this point.

    Cheers,
    _

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

    Default Re: How to implement nested editable lists in C++ as models in Qt (QML oriented)

    Quote Originally Posted by anda_skoa View Post
    I don't think QtQuick can deal with tree models at this point.
    It can deal with tree models with the use of VisualDataModel element which allows to set the root index to traverse different layers of the model within the view.
    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.


Similar Threads

  1. Nested lists in QT QML
    By Raghavendra R M in forum Qt Quick
    Replies: 13
    Last Post: 14th October 2013, 10:27
  2. Replies: 7
    Last Post: 28th April 2013, 00:46
  3. nested lists in QTextDocumentFragment::toHtml()
    By Al_ in forum Qt Programming
    Replies: 0
    Last Post: 2nd March 2012, 09:16
  4. Editable Models
    By MTK358 in forum Newbie
    Replies: 1
    Last Post: 9th September 2010, 19:58

Tags for this Thread

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.