Results 1 to 4 of 4

Thread: Mapper from QList to QTable* display

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    May 2008
    Posts
    2
    Qt products
    Qt4 Qt/Embedded
    Platforms
    MacOS X Windows

    Default Mapper from QList to QTable* display

    Is there a Mapper from a QList to the items of a QTable? I have a rapidly changing application and i'm finding myself resetting up 20-30 columns and headers. I could subclass it, but there are some instances where the list comes from a sql query instead of the object itself.

    All i really need to do is view it and change order, and some of the options seem like overkill.

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

    Default Re: Mapper from QList to QTable* display


  3. #3
    Join Date
    May 2008
    Posts
    2
    Qt products
    Qt4 Qt/Embedded
    Platforms
    MacOS X Windows

    Default Re: Mapper from QList to QTable* display

    What I meant was that I want to actually bind the two (QList to QModel) for the ordering. Later operations are defined on a QList, not a Model class.

    I have an approach that sends a signal to the underlying list to reorder (moveUp / moveDown), then recreates the whole model. This seems sort of clumsy.

    Alternatively i could subclass the model, but again, It seems like I would need to do the same thing, or make the same switch twice in the model and the underlying list. Again any operation that reorders the list would need to repopulate the whole model.

    Is there a clean way to bind the model to the list a single time?

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

    Default Re: Mapper from QList to QTable* display

    The model should operate directly on the list. So your list should be "inside" the model or there should be no list at all - do everything using the model interface.

    Remember that the model is not "something that lets me display my data in a table" but it's means to access some arbitrary data through a unified interface. Simply make your application aware of the model - let it help you instead of getting in your way.

    Maybe this blog entry helps you understand things a bit more:
    http://blog.wysota.eu.org/index.php/...ta-redundancy/

Similar Threads

  1. Sorting using qSort(), - if QList contains POINTERS
    By joseph in forum Qt Programming
    Replies: 13
    Last Post: 18th August 2013, 18:55
  2. Display only PNG image on desktop
    By durbrak in forum Qt Programming
    Replies: 32
    Last Post: 15th March 2008, 21:55
  3. Possible signal mapper problem
    By MarkoSan in forum Qt Programming
    Replies: 13
    Last Post: 25th January 2008, 13:11
  4. Accessing QList Objects
    By magikalpnoi in forum Qt Programming
    Replies: 7
    Last Post: 21st September 2006, 20:43

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.