Giter Site home page Giter Site logo

pyqmlsortfilterproxymodel's Introduction

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.

pyqmlsortfilterproxymodel's People

Contributors

dogezen avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

dan178a

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.