Results 1 to 2 of 2

Thread: Setting CurrentIndex of comboBox with model

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Oct 2007
    Posts
    9
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Setting CurrentIndex of comboBox with model

    I have combobox with model like this
    Qt Code:
    1. cityModel = new QSqlTableModel(this);
    2. cityModel->setTable("cities"); // (city_id, city_name)
    3. cityModel->select();
    4. comboBox_city->setModel(cityModel);
    5. comboBox_city->setModelColumn(1);
    6. comboBox_city->setCurrentIndex(0);
    To copy to clipboard, switch view to plain text mode 

    I want to change current index of combobox to row of city_id has 15 value?
    Please help me.

    Following line doesnt work.
    Qt Code:
    1. comboBox_city->setCurrentIndex(comboBox_city->findData(query.value(rec.indexOf("city_id"))) );
    To copy to clipboard, switch view to plain text mode 
    Last edited by wysota; 16th November 2007 at 12:02. Reason: missing [code] tags

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.