Results 1 to 2 of 2

Thread: QComboBox and QSqlRelationalTableModel

  1. #1
    Join Date
    May 2017
    Posts
    1
    Qt products
    Qt5
    Platforms
    MacOS X Windows

    Lightbulb QComboBox and QSqlRelationalTableModel

    Hello,

    I'm trying to fill a QComboBox with my QSqlRelationalTableModel this way:

    First I populate my model:
    model->setTable();
    model->select();
    model->setRelation();

    After that I set the model for my QComboBox:

    comboBox->setModel(model);
    comboBox->setModelColumn(2);

    And I use a QDataWidgetMapper:

    mapper->setItemDelegate(new QSqlRelationalDelegate(this));
    mapper->setModel(model);
    mapper->addMapping(comboBox,2);

    Following this post:

    http://www.qtcentre.org/threads/2435...onalTableModel

    The point is, the comboBox is actually filled (I can print all its values on the prompt) but nothing appears in the QComboBox.
    I'm assuming that it may be a format problem? Or it's about the Qt:isplayRole but I didn't find a proper way to make it works.

    Thanks for your help

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

    Default Re: QComboBox and QSqlRelationalTableModel

    You definitely need to set the relational delegate on the combobox. There is no need to use QDataWidgetMapper here.
    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. Replies: 1
    Last Post: 20th May 2015, 11:21
  2. Replies: 2
    Last Post: 29th December 2012, 14:14
  3. QSqlRelationalTableModel and editable QComboBox
    By cia.michele in forum Qt Programming
    Replies: 1
    Last Post: 9th October 2012, 12:01
  4. when to use QSqlRelationalTableModel?
    By babygal in forum Qt Programming
    Replies: 1
    Last Post: 5th October 2010, 09:19
  5. QSqlRelationalTableModel
    By marvin in forum Newbie
    Replies: 2
    Last Post: 19th November 2008, 21:29

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.