Pages
API Documentation
On this page

KCheckableProxyModel Class

Adds a checkable capability to a source model. More...

  • Header: #include <KCheckableProxyModel>
  • CMake: find_package(KF6 REQUIRED COMPONENTS ItemModels)
    target_link_libraries(mytarget PRIVATE KF6::ItemModels)
  • Inherits: QIdentityProxyModel

List of all members, including inherited members

Public Functions

Protected Functions

Detailed Description

Items is standard Qt views such as QTreeView and QListView can have a checkable capability and draw checkboxes. Adding such a capability requires specific implementations of the data() and flags() virtual methods. This class implements those methods generically so that it is not necessary to implement them in your model.

This can be combined with a KSelectionProxyModel showing the items currently selected

QItemSelectionModel *checkModel = new QItemSelectionModel(rootModel, this);
KCheckableProxyModel *checkable = new KCheckableProxyModel(this);
checkable->setSourceModel(rootModel);
checkable->setSelectionModel(checkModel);

QTreeView *tree1 = new QTreeView(vSplitter);
tree1->setModel(checkable);
tree1->expandAll();

KSelectionProxyModel *selectionProxy = new KSelectionProxyModel(checkModel, this);
selectionProxy->setFilterBehavior(KSelectionProxyModel::ExactSelection);
selectionProxy->setSourceModel(rootModel);

QTreeView *tree2 = new QTreeView(vSplitter);
tree2->setModel(selectionProxy);

Member Function Documentation

[explicit] KCheckableProxyModel::KCheckableProxyModel(QObject *parent = nullptr)

[virtual protected] bool KCheckableProxyModel::select(const QItemSelection &selection, QItemSelectionModel::SelectionFlags command)

QItemSelectionModel *KCheckableProxyModel::selectionModel() const

See also setSelectionModel()

void KCheckableProxyModel::setSelectionModel(QItemSelectionModel *itemSelectionModel)

See also selectionModel()

We use cookies to personalize content and to analyze our traffic. Please decide if you are willing to accept cookies from our website.