Results 1 to 4 of 4

Thread: Getting model to submit data when using QDataWidgetMapper

  1. #1
    Join Date
    Jun 2006
    Posts
    43
    Thanks
    9
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Getting model to submit data when using QDataWidgetMapper

    When using QDataWidgetMapper one can trigger a submit() in the model, which I have verified is happening. My model happens to be QSqlQueryModel.

    How is my model supposed to get the current values and see if they have "changed"? Either it gets them directly from the widgets or the mapper. I would expect the mapper to help some here, since it is the go-between.

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

    Default Re: Getting model to submit data when using QDataWidgetMapper

    The question is a bit strange... The model holds the data thus knowing "current" values is just a matter of looking into its data structures. If you want to find which data needs submiting, then your model needs to track that for example by setting some flag on the data from its setData() method and clearing that flag when the data is submitted into the storage.

    The data widget mapper's submit() call submits the data from the mapper to the model. Calling model's submit() at that moment is only a side effect. The whole logic is inside the mapper that probably just calls setData() on each mapped column/row widget that has the modified flag set.

  3. #3
    Join Date
    Jun 2006
    Posts
    43
    Thanks
    9
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Getting model to submit data when using QDataWidgetMapper

    I added some output to both the mapper and the model verifying that submit() is being called on both. QSqlQueryModel::setData() is not being called, so if the QDataWidgetMapper has that responsibility then I have missed a configuration option somewhere.

    I think the mapper merely calls submit() on the model and leaves it up to the model to change any data that needs changing.

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

    Default Re: Getting model to submit data when using QDataWidgetMapper

    QSqlQueryModel is a read only model. It won't call setData().

Similar Threads

  1. QMap model data
    By gyre in forum Newbie
    Replies: 3
    Last Post: 9th December 2007, 22:19
  2. Model - data
    By gyre in forum Newbie
    Replies: 1
    Last Post: 9th December 2007, 19:49
  3. Data model
    By steg90 in forum Qt Programming
    Replies: 3
    Last Post: 17th September 2007, 12:14
  4. Custom Model Class
    By mattjgalloway in forum Qt Programming
    Replies: 12
    Last Post: 4th June 2007, 17:30
  5. Informing a model its data has changed
    By saknopper in forum Newbie
    Replies: 3
    Last Post: 17th January 2007, 19:58

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.