-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_cursor_qwidget.py
More file actions
68 lines (54 loc) · 1.61 KB
/
test_cursor_qwidget.py
File metadata and controls
68 lines (54 loc) · 1.61 KB
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
61
62
63
64
65
66
67
68
import sys
from PySide6.QtWidgets import QApplication, QWidget, QVBoxLayout
from PySide6.QtQuick import QQuickView
from PySide6.QtCore import QUrl, Qt
from PySide6.QtGui import QCursor
app = QApplication(sys.argv)
view = QQuickView()
view.setResizeMode(QQuickView.SizeRootObjectToView)
qml = b"""
import QtQuick
import QtQuick.Controls
import QtQuick.Layouts
Item {
width: 600; height: 400
ColumnLayout {
anchors.fill: parent
spacing: 0
Rectangle { color: "red"; Layout.fillWidth: true; Layout.preferredHeight: 40 }
SplitView {
id: split
Layout.fillWidth: true
Layout.fillHeight: true
orientation: Qt.Horizontal
handle: Rectangle {
implicitWidth: 7
color: "magenta"
}
Rectangle { SplitView.minimumWidth: 50; width: 100; color: "blue" }
Rectangle {
SplitView.fillWidth: true; color: "green"
HoverHandler { cursorShape: Qt.PointingHandCursor }
}
}
}
}
"""
import tempfile
with tempfile.NamedTemporaryFile("wb", suffix=".qml", delete=False) as f:
f.write(qml)
path = f.name
view.setSource(QUrl.fromLocalFile(path))
window = QWidget()
layout = QVBoxLayout(window)
layout.setContentsMargins(0, 0, 0, 0)
container = QWidget.createWindowContainer(view, window)
layout.addWidget(container)
window.resize(600, 400)
window.show()
def check():
print("Test running - fresh snapshot test for undo")
app.quit()
from PySide6.QtCore import QTimer
QTimer.singleShot(1000, check)
app.exec()