Results 1 to 3 of 3

Thread: QDataWidgetMapper and QComboBox: Make mapper read currentIndex

  1. #1
    Join Date
    Oct 2010
    Posts
    6
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default QDataWidgetMapper and QComboBox: Make mapper read currentIndex

    Hi. I have the following situation: A QComboBox holds the 7 days of the week. It is filled using the QDate::longDayName() function so i get the dates in the right language. An Additional "select day" entry is inserted at the top so that the indexes correspond with the Dayofweek numbers from Qt.

    The model (stored in a db) that i want to change has several fields, the one in question being the "dayofweek" field. For the mapper I tried
    Qt Code:
    1. mapper->addMapping(ui.comboBox, model->fieldIndex("dayofweek"));
    To copy to clipboard, switch view to plain text mode 
    but that doesn't work. What I want it to do is store the current index in the "dayofweek"-column of the model. All other values (lineedits and such) work fine.

    How would I go about doing this? The tutorials I found on the web use QRelationalSqlTable as a base but since i want the weekdays internationalised this is not an option.

  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: Make mapper read currentIndex

    Pass "currentIndex" as the third parameter to addMapping().
    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. The following user says thank you to wysota for this useful post:

    hefeweiz3n (18th October 2010)

  4. #3
    Join Date
    Oct 2010
    Posts
    6
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QDataWidgetMapper and QComboBox: Make mapper read currentIndex

    Thanks, that did the trick.

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

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.