salut tous le monde
en faite je suis debutant en PyQt, donc ma question est:
comment passer d'une ApplicationWindow QML a une autre en utilisant PyQt?
merci
Version imprimable
salut tous le monde
en faite je suis debutant en PyQt, donc ma question est:
comment passer d'une ApplicationWindow QML a une autre en utilisant PyQt?
merci
:salut:
Vague est la question…
:cristal:
Tu peux jeter un coup d'œil à http://ceg.developpez.com/tutoriels/...faces-simples/, http://ceg.developpez.com/tutoriels/...on-qml-python/ et http://ceg.developpez.com/tutoriels/...ramme-complet/, ça parle de comunication entre Qt Quick et PyQt.
j'ai essayé de faire quelque chose mais j'ai obtenu ca comme erreur :
voici mon code main.py:Code:
1
2 win = engine.rootObjects()[0] IndexError: list index out of range
et ma main.qml:Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15 import sys from PyQt5.QtWidgets import QApplication from PyQt5.QtQml import QQmlApplicationEngine,QQmlEngine, QQmlComponent from PyQt5.QtCore import QObject, pyqtSlot, QVariant,QUrl if __name__ == "__main__": app = QApplication(sys.argv) engine = QQmlApplicationEngine() engine.load('main.qml') win = QObject() win = engine.rootObjects()[0] win.show() sys.exit(app.exec_())
Code:
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
58
59
60 import QtQuick 2.7 import QtQuick.Controls 2.0 import QtQuick.Layouts 1.0 ApplicationWindow { id : root visible: true width: 1000 height: 800 title: qsTr("ACTEMIUM") SwipeView { id: swipeView anchors.fill: parent currentIndex: tabBar.currentIndex Page1 { Label { text: qsTr("Page1") anchors.centerIn: parent } } Page2 { Label { text: qsTr("Second page") anchors.centerIn: parent } } Page3 { Label { text: qsTr("Troisieme page") anchors.centerIn: parent } } } footer: TabBar { id: tabBar currentIndex: swipeView.currentIndex TabButton { text: qsTr("First") } TabButton { text: qsTr("Second") } TabButton { text: qsTr("Trois") } } }
je me demande si c'est juste une limitation de PyQt5 ne supportant pas les versions actuelles de QML le "swipeView" surtout?