SliceFilterProxyModel
Qt Base Class: QIdentityProxyModel
Signature: QIdentityProxyModel(self, parent: Optional[PySide6.QtCore.QObject] = None) -> None
Base classes
Name | Children | Inherits |
---|---|---|
SliceIdentityProxyModel prettyqt.itemmodels.proxies.sliceidentityproxymodel |
⋔ Inheritance diagram
graph TD
1473290718896["itemmodels.SliceFilterProxyModel"]
1473290716944["itemmodels.SliceIdentityProxyModel"]
1473299892128["core.IdentityProxyModel"]
1473299903840["core.AbstractProxyModelMixin"]
1473299890176["core.AbstractItemModelMixin"]
1473299815024["core.ObjectMixin"]
140713234304496["builtins.object"]
1473289064768["QtCore.QIdentityProxyModel"]
1473289061840["QtCore.QAbstractProxyModel"]
1473289050128["QtCore.QAbstractItemModel"]
1473288842240["QtCore.QObject"]
1473291690208["Shiboken.Object"]
1473290716944 --> 1473290718896
1473299892128 --> 1473290716944
1473299903840 --> 1473299892128
1473299890176 --> 1473299903840
1473299815024 --> 1473299890176
140713234304496 --> 1473299815024
1473289064768 --> 1473299892128
1473289061840 --> 1473289064768
1473289050128 --> 1473289061840
1473288842240 --> 1473289050128
1473291690208 --> 1473288842240
140713234304496 --> 1473291690208
🛈 DocStrings
Bases: SliceIdentityProxyModel
Proxy model to filter an item view based on python slicing syntax.
Since slicing operations are bijective, this model can filter without looping through rows or columns. Thus, this should perform much better than a SortFilterProxyModel with a column filter. (O(1) instead of O(n))
Example
To filter out every second row, and cut off the the first two columns:
model = MyModel()
table = widgets.TableView()
table.set_model(model)
table.proxifier[::2, 2:].filter()
table.show()
# or
indexer = (slice(None, None, 2), slice(2, None))
proxy = itemmodels.SliceFilterProxyModel(indexer=indexer)
proxy.set_source_model(model)
table.set_model(proxy)
table.show()
Source code in prettyqt\itemmodels\proxies\slicefilterproxymodel.py
headerData(section: int, orientation: constants.Orientation, role: constants.ItemDataRole = constants.DISPLAY_ROLE)
Map header data to proxy by calculating position from slice values.
source pos = slice start + proxy pos * slice step)
Source code in prettyqt\itemmodels\proxies\slicefilterproxymodel.py
mapFromSource(source_index: core.ModelIndex) -> core.ModelIndex
Map index from source by calculating position based on slice values.
proxy pos = source pos - slice start / slice step
Source code in prettyqt\itemmodels\proxies\slicefilterproxymodel.py
mapToSource(proxy_idx: core.ModelIndex) -> core.ModelIndex
Map index to source by calculating position from slice values.
source pos = slice start + proxy pos * slice step)
Source code in prettyqt\itemmodels\proxies\slicefilterproxymodel.py
Info
This is a slice proxy and can be selectively applied to a model. Read more about slices.
⌗ Property table
Qt Property | Type | Doc |
---|---|---|
objectName |
QString | |
sourceModel |
QAbstractItemModel | |
column_slice |
QVariantList | Column slice to include for the proxy |
row_slice |
QVariantList | Row slice to include for the proxy |