Results 1 to 2 of 2

Thread: How to set the QComboBox's default index when it working under the model/view ?

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1

    Default How to set the QComboBox's default index when it working under the model/view ?

    here is my codes:
    Qt Code:
    1. #include <QtGui>
    2.  
    3. int main(int argc, char **argv)
    4. {
    5. QApplication app(argc,argv);
    6. QDirModel* model = new QDirModel();
    7. QTreeView* view = new QTreeView();
    8. view->setModel(model);
    9. QComboBox* combo = new QComboBox();
    10. combo->setView(view);
    11. combo->setModel(model);
    12. combo->show();
    13. QString root = "D:/";/*QDir::rootPath();*/
    14. combo->setRootModelIndex((static_cast<QDirModel*>(combo->model()))->index(root));
    15. app.exec();
    16. }
    To copy to clipboard, switch view to plain text mode 

    the ComboBox always show the root as "C:",how can I set it to the "D:"?

    I'm using Qt 4.4.0.If you use the old version such as 4.3.1,there will be a few other bugs.

    thanks a lot.
    Last edited by jpn; 13th June 2008 at 18:55. 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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.