blob: 21cfdea77b5ce76803fb18a960e056ae007c32c3 (
plain)
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
|
//! [0]
def main():
if Qt.Q_WS_X11
useGUI = getenv("DISPLAY") != 0
else:
useGUI = True
app = QApplication(sys.argv, useGUI)
if useGUI:
# start GUI version
...
else:
# start non-GUI version
...
return app.exec_()
//! [0]
//! [1]
QApplication.setStyle(QWindowsStyle())
//! [1]
//! [2]
def main():
QApplication.setColorSpec(QApplication.ManyColor)
QApplication app(sys.argv)
...
return app.exec_()
//! [2]
//! [3]
class MyWidget (QWidget):
# ...
def sizeHint(self):
return QSize(80, 25).expandedTo(QApplication.globalStrut())
//! [3]
//! [4]
def showAllHiddenTopLevelWidgets():
for widget in QApplication.topLevelWidgets():
if widget.isHidden():
widget.show()
//! [4]
//! [5]
def updateAllWidgets():
for widget in QApplication.allWidgets()
widget.update()
//! [5]
//! [6]
if __name__ == '__main__':
QApplication.setDesktopSettingsAware(False)
app = QApplication(sys.argv)
# ...
return app.exec_()
//! [6]
//! [7]
if (startPos - currentPos).manhattanLength() >= QApplication.startDragDistance():
startTheDrag()
//! [7]
//! [8]
class MyApplication (QApplication):
# ...
def commitData(QSessionManager& manager)
if manager.allowsInteraction():
ret = QMessageBox.warning(
mainWindow,
QObject.tr("My Application"),
QObject.tr("Save changes to document?"),
QMessageBox.Save | QMessageBox.Discard | QMessageBox.Cancel)
if ret == QMessageBox.Save:
manager.release()
if not saveDocument():
manager.cancel()
elif ret == QMessageBox.Discard:
pass
else:
manager.cancel()
else:
# we did not get permission to interact, then
# do something reasonable instead
pass
//! [8]
//! [9]
appname -session id
//! [9]
//! [10]
for command in mySession.restartCommand():
do_something(command)
//! [10]
//! [11]
for command in mySession.discardCommand():
do_something(command)
//! [11]
//! [12]
widget = qApp.widgetAt(x, y)
if widget:
widget = widget.window()
//! [12]
//! [13]
widget = qApp.widgetAt(point)
if widget:
widget = widget.window()
//! [13]
|