Skip to content

PySide implementation of QML exposed QSortFilterProxyModel

License

MIT, MIT licenses found

Licenses found

MIT
LICENSE
MIT
LICENSE-Third-Party
Notifications You must be signed in to change notification settings

dogezen/PyQmlSortFilterProxyModel

Repository files navigation

PyQmlSortFilterProxyModel

This project is a python PySide6 port of https://github.com/oKcerG/SortFilterProxyModel; a QSortFilterProxyModel exposed to QML written by oKcerG.

Please refer to oKcerG's documentation for usage as much of this implementation is based on oKcerG's implementation.

Note: the version of the qml exposed SortFilterProxyModel is 0.2 to match that of oKcerG's project so that existing .qml code from your projects can be re-used quickly.

Components not (yet) ported

  • ProxyRoles
  • QQmlSortFilterProxyModel::componentCompleted. In PySide6, there is no Q_INTERFACES macro enabling a class to inherits from QSortFilterProxyModel and QQmlParserStatus. Hence inheriting from QQmlParserStatus doesn't cause errors, however the componentCompleted method is not called.
  • Some of the sorters are not yet ported
  • The delay functionality is not ported
  • Attached properties not ported

Differences - Container Filters

Because attached properties are not ported, there is a difference in using the AnyOf and AllOf filters:

// oKcerG's
AnyOf {
    RoleFilter {...}
    RegExpFilter {...}
    //...
}

// python implementation
AnyOf {
    // need to assign a list of Filter to the filters property
    filters: [
        RoleFilter {...},
        RegExpFilter {...},
        //...
    ]
}

Usage

  1. download /clone the repostitory
  2. copy src/qmlsortfilterproxymodel to your project
  3. import and register the SortFilterProxyModel to qml
# main.py
import qmlsortfilterproxymodel
# register qml types before QQmlApplicationEngine.load("main.qml") is called
qmlsortfilterproxymodel.registerQmlTypes()
  1. Instantiate SortFilterProxyModel in qml
// SomeFile.qml
import SortFilterProxyModel 0.2


SortFilterProxyModel {
    //...
}

Running the Example

  1. Create a virtual environment (currently venv folder is under .gitignore) and activate python3 -m venv venv source venv/bin/activate
  2. Install requirements (PySide6) pip3 install -r requirements.txt
  3. Run the example project python3 example/main.py

Once the example window launches, you can use the TextField to filter by name.

About

PySide implementation of QML exposed QSortFilterProxyModel

Resources

License

MIT, MIT licenses found

Licenses found

MIT
LICENSE
MIT
LICENSE-Third-Party

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published