bonjour a tous.

ma question est Comment puis-je utiliser ce SortFilterProxyModel https://github.com/oKcerG/SortFilterProxyModel qui est en c ++ avec PyQt.

quand j'execute le programme avec c++ tout marche bien, mais quand j'utilise le Pyqt çà ne marche pas !!!!

voici mon code "main.qml":

Code QML : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import QtQuick 2.2
import QtQuick.Controls 2.1
 
import SortFilterProxyModel 0.2
 
ApplicationWindow {
    visible: true
    width: 640
    height: 480
 
    ListModel {
        id: personModel
        ListElement {
            firstName: "Erwan"
            lastName: "omiti"
            favorite: true
        }
 
        ListElement {
            firstName: "Omiri"
            lastName: "Castex"
            favorite: true
        }
        ListElement {
            firstName: "momo"
            lastName: "momo"
            favorite: true
        }
        ListElement {
            firstName: "toto"
            lastName: "toto"
            favorite: true
        }
        // ...
    }
 
    TextField {
        id: textField
        anchors { top: parent.top; left: parent.left; right: parent.right }
        height: implicitHeight
    }
 
    SortFilterProxyModel {
        id: personProxyModel
        sourceModel: personModel
        filterRoleName: "lastName"
        filterPattern: textField.text
        filterCaseSensitivity: Qt.CaseInsensitive
        sortRoleName: "FirstName"
    }
 
    ListView {
        anchors { top: textField.bottom; bottom: parent.bottom; left: parent.left; right: parent.right }
        model: personProxyModel
        delegate: Text { text: firstName + " " + lastName}
    }
}

sachons que dans le module SortFilterProxyModel qui est en C++ j'ai les fichier suivant :

filter.h qqmlSortFilterProxyModel.h
filter.cpp qqmlSortFilterProxyModel.cpp

et voici mon code PyQt:

Code PyQt : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#!/usr/bin/env python
# -*- coding: utf-8 -*-
 
 
import sys
 
from PyQt5.QtWidgets import QApplication
from PyQt5.QtQml import QQmlApplicationEngine
from PyQt5.QtCore import QObject, pyqtSlot, QVariant,QUrl
 
 
 
if __name__ == "__main__":
 
    app = QApplication(sys.argv)
    engine = QQmlApplicationEngine()
    engine.load('main.qml')
    win = engine.rootObjects()[0]
    win.show()
    sys.exit(app.exec())

donc est ce que il y'a une astuces pour résoudre ce problème ??

merci d'avance.