Results 1 to 8 of 8

Thread: QComboBox with QSqlQueryModel

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #5
    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: QComboBox with QSqlQueryModel

    Quote Originally Posted by L.Marvell View Post
    I didn't do anything special. I have the ui with QComboBox with SizeAdjustPolicy set to adjustToContents (not on first show)
    Qt Code:
    1. modelCategories = new QSqlQueryModel;
    2. ...
    3. // connecting to PostgreSQL database
    4. ...
    5. modelCategories->setQuery("SELECT category_name FROM mytable");
    6. comboBox->setModel(modelCategories);
    To copy to clipboard, switch view to plain text mode 
    There's not much I can do with that piece of code. I wanted to test and see myself, that's why I asked for something compilable to test with.

    I took one of the SQL examples shipped with Qt and modified it to use combo boxes instead of tables. The attached example seems to work pretty fine for me. Does it work for you?
    Attached Files Attached Files
    J-P Nurmi

Similar Threads

  1. using QComboBox as an ItemView
    By EricTheFruitbat in forum Qt Programming
    Replies: 3
    Last Post: 24th January 2007, 16:14
  2. QDataWidgetMapper <=> QComboBox best practice
    By saknopper in forum Qt Programming
    Replies: 1
    Last Post: 18th January 2007, 10:50
  3. QSqlQueryModel + set Write
    By raphaelf in forum Qt Programming
    Replies: 7
    Last Post: 5th June 2006, 08:55
  4. QcomboBox items
    By therealjag in forum Newbie
    Replies: 5
    Last Post: 27th March 2006, 08:21
  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
  •  
Qt is a trademark of The Qt Company.