Results 1 to 5 of 5

Thread: QDataWidgetMapper and QComboBox

  1. #1
    Join Date
    Jun 2010
    Location
    Cincinnati, Ohio, USA
    Posts
    92
    Thanks
    3
    Qt products
    Qt4
    Platforms
    Windows

    Question QDataWidgetMapper and QComboBox

    I have the classical QSqlRelationalTableModel situation where the customerModel is the master and the countryModel is the detail. The problem is that I don't want to display this model in a table, but show one record at a time in individual widgets using the QDataWidgetMapper.

    How do I wire up the QComboBox that allows the user to pick the country?

    Possible options:

    1. Make the customerModel a QSqlTableModel, pass a 3rd param to the addMapper function
    2. Make the customerModel a QSqlRelationalTableModel, wire up the relationship, and Qt does the rest.
    3. something else

  2. #2
    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: QDataWidgetMapper and QComboBox

    Use QSqlRelationalDelegate on the widget mapper.
    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.


  3. #3
    Join Date
    Jun 2010
    Location
    Cincinnati, Ohio, USA
    Posts
    92
    Thanks
    3
    Qt products
    Qt4
    Platforms
    Windows

    Question Re: QDataWidgetMapper and QComboBox

    Ok, let me see if I understand what you mean.

    1. the customerModel needs to be QSqlRelationalTableModel
    2. Wire up the relationship to the countryModel
    3. Create a QDataWidgetMapper
    4. Make the mappers delegate the QSqlRelationalDelegate
    5. Add a mapping for the QComboBox


    Correct?

  4. #4
    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: QDataWidgetMapper and QComboBox

    Yes, something 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.


  5. #5
    Join Date
    Jun 2010
    Location
    Cincinnati, Ohio, USA
    Posts
    92
    Thanks
    3
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QDataWidgetMapper and QComboBox

    Tried that and it did not work

Similar Threads

  1. Replies: 2
    Last Post: 29th December 2012, 15:14
  2. QItemDelegate, QDataWidgetMapper and QComboBox
    By cydside in forum Qt Programming
    Replies: 7
    Last Post: 8th April 2009, 19:44
  3. QDataWidgetMapper and QComboBox
    By mazurekwrc in forum Qt Programming
    Replies: 0
    Last Post: 31st March 2009, 14:02
  4. QDataWidgetMapper and QCombobox
    By miraks in forum Qt Programming
    Replies: 4
    Last Post: 6th December 2008, 18:53
  5. QDataWidgetMapper <=> QComboBox best practice
    By saknopper in forum Qt Programming
    Replies: 1
    Last Post: 18th January 2007, 11:50

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.