combo->addItems(QStringList() << "B" << "C" << "A"); // "B","C","A" // for sorting you need the following 4 lines QSortFilterProxyModel* proxy = new QSortFilterProxyModel(combo); // <-- proxy->setSourceModel(combo->model()); // <-- // combo's current model must be reparented, // otherwise QComboBox::setModel() will delete it combo->model()->setParent(proxy); // <-- combo->setModel(proxy); // <-- // sort combo->model()->sort(0); // "A","B","C"
Brak komentarzy:
Prześlij komentarz