Results 1 to 3 of 3

Thread: QComboBox QSqlQueryModel & relation.

  1. #1
    Join Date
    Jun 2007
    Posts
    12
    Qt products
    Qt4
    Platforms
    Unix/X11

    Cool QComboBox QSqlQueryModel & relation.

    Hi..

    I have a form to show/edit data from a query, currently I am just showing data, this is not in a table so its line edits e.t.c.

    I use a QSqlQueryModel with QDataWidgetMapper to get the data to display which is fine for plain data from the table, but as a good db guy, i use relations as well..

    So, I have a QComboBox who's list items are filled by a QSqlQueryModel that gives two rows, a primary key and display text.. what I want to do is link the primary key to a value in my first query model to show the correct display text.. Any ideas?

    I dont mind sub-classing the QComboBox, but would like to avoid it if I can..


    Qt 4.3.0, Fedora Core 7 x86_64, QDevelop

  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: QComboBox QSqlQueryModel & relation.

    This should help:
    Qt Code:
    1. dataWidgetMapper->setItemDelegate(new QSqlRelationalDelegate(dataWidgetMapper));
    To copy to clipboard, switch view to plain text mode 

  3. #3
    Join Date
    Jun 2007
    Posts
    12
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: QComboBox QSqlQueryModel & relation.

    I will look into it, at the moment I have hard-coded lookups into the combo, I might have to sub-class a combobox to handle key values, then it might work as I would like..


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.