Results 1 to 2 of 2

Thread: qcombobox with multiple columns

  1. #1
    Join Date
    Dec 2013
    Posts
    20
    Thanks
    4
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default qcombobox with multiple columns

    Hello,

    I'm trying show QTableView in QComboBox.

    Example Department is table in my database.

    Query =

    SELECT Dep.Code,Dep.Name FROM Dep
    and I've tried this my code.

    Qt Code:
    1. QSqlQueryModel* depModel = new QSqlQueryModel();
    2. depModel->setQuery("SELECT Dep.Code,Dep.Name FROM Dep");
    3. .
    4. .
    5. .
    6. QTableView* cboxTable = new QTableView(this);
    7. cboxTable->setModel(depModel);
    8. QComboBox *courseComboBox = new QComboBox();
    9. courseComboBox->setView(cboxTable);
    To copy to clipboard, switch view to plain text mode 

    but not work.Where is my problem ? I want see multiple columns.

    Here is this problem stackoverflow link

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: qcombobox with multiple columns

    What "does not work" about it? You see no data, no drop down, no columns, only one column, the wrong value when selected, pink MS Comic Sans text? Where do you set the model on the combo box?

Similar Threads

  1. QCombobox with multiple columns
    By grantbj74 in forum Qt Programming
    Replies: 4
    Last Post: 5th March 2014, 05:13
  2. Replies: 1
    Last Post: 6th December 2012, 19:56
  3. Width QTableView for QCombobox with multiple columns
    By visor_ua in forum Qt Programming
    Replies: 7
    Last Post: 21st June 2011, 10:54
  4. Need to have columns in QComboBox
    By anju123 in forum Qt Programming
    Replies: 6
    Last Post: 6th July 2009, 22:04
  5. QCompleter on multiple columns
    By akiross in forum Qt Programming
    Replies: 0
    Last Post: 9th November 2008, 16:15

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.