Results 1 to 2 of 2

Thread: FOREIGN KEY + QComboBox

  1. #1
    Join Date
    Nov 2006
    Posts
    96

    Default FOREIGN KEY + QComboBox

    Hi, I've created an application that's based on mysql table.

    Mysql table has FOREIGN KEYs set from first tables's field (town) to second table's field (also town)


    What I want to do now is to add a QComboBox (that points to the first table's field town, but when I click drop-down button I want to display the values that are stored in second table's field (town) and write that town to the first table's field.

    The problem is that I want to automatically detect that mysql table's field have relations set (with FOREIGH KEY) so that dropdown menu can display itself properly.

    Any ideas how to do that?

  2. #2
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: FOREIGN KEY + QComboBox

    QSqlRelationalTableModel and QSqlRelationalDelegate can handle relations for you, but I'm afraid you will have to establish relations by hand. I have no idea whether it's possible with Qt to detect possible relations in any arbitrary table.
    J-P Nurmi

Similar Threads

  1. QComboBox drop list button events
    By maird in forum Qt Programming
    Replies: 5
    Last Post: 20th October 2007, 19:25
  2. QComboBox in QTableWidget : display troubles.
    By Nyphel in forum Qt Programming
    Replies: 2
    Last Post: 13th October 2007, 23:29
  3. using QComboBox as an ItemView
    By EricTheFruitbat in forum Qt Programming
    Replies: 3
    Last Post: 24th January 2007, 16:14
  4. QDataWidgetMapper <=> QComboBox best practice
    By saknopper in forum Qt Programming
    Replies: 1
    Last Post: 18th January 2007, 10:50
  5. QComboBox +SUSE10.0 +qt4.1 strange behavior
    By antonio.r.tome in forum Qt Programming
    Replies: 6
    Last Post: 20th March 2006, 17:49

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.