There's no direct relation between QComboBox and QSortFilterProxyModel.
QComboBox can serve as an item delegate in an item view (QTreeView, QTableView) to give the user a choice for data entry.
You will find more about item delegates in the Qt documentation.
Just to give an idea how it works. If the item delegate (in thie example a class with name "IemDelegate") is registered with a view the "createEditor" method is called from the view when needed to give user the option to enter a value from the combo box:
const QStyleOptionViewItem& option,
const QModelIndex& index) const
{
editor->addItem("Entry 1");
editor->addItem("Entry 2");
editor->addItem("Entry 3");
return editor;
}
QWidget* ItemDelegate::createEditor(QWidget* parent,
const QStyleOptionViewItem& option,
const QModelIndex& index) const
{
QComboBox* editor = new QComboBox(parent);
editor->addItem("Entry 1");
editor->addItem("Entry 2");
editor->addItem("Entry 3");
return editor;
}
To copy to clipboard, switch view to plain text mode
Since the "createEditor" method gets the QModelIndex for the data to be edited you can access the related model if really necessary:
index.model();
index.model();
To copy to clipboard, switch view to plain text mode
If your view has a QSortFilterProxyModel attached then the model returned above is exactly this.
Regards
Ernst
Bookmarks