3ShZGYNMUJQTYHf0lV9LI0 changeset

Changeset313661333563 (b)
ParentNone (a)
ab
0+# Author: Tomi Saarinen, Rohea Oy
0+# License: Do what you feel like but we guarantee nothing.
0+import sys
0+from PySide.QtCore import *
0+from PySide.QtGui import *
0+
0+class StackedWindow(QMainWindow):
0+    def __init__(self):
0+        QMainWindow.__init__(self)
0+        # This attribute makes the whole Stacked Window thing work
0+        self.setAttribute(Qt.WA_Maemo5StackedWindow)
0+        # Create button and layout
0+        self.cw = QWidget(self)
0+        self.setCentralWidget(self.cw)       
0+        self.vbox = QVBoxLayout(self.cw) 
0+        self.button = QPushButton(self)
0+        self.button.setText(QString("Push me")) 
0+        self.vbox.addWidget(self.button)
0+        # Create subwindow
0+        self.subWindow = SubWindow(self)
0+        # Hide subwindow at first
0+        self.subWindow.hide()
0+        # Connect button to signal
0+        self.connect(self.button, SIGNAL("clicked()"), self.subWindow.show)
0+
0+class SubWindow(QMainWindow):
0+    def __init__(self, parent):
0+        # Notice that you must give a parent window as parameter to the constuctor
0+        QMainWindow.__init__(self, parent)
0+        # Also set the Stacked Window parameter for every subwindow in the stack
0+        self.setAttribute(Qt.WA_Maemo5StackedWindow)
0+        # Just some content...
0+        self.label = QLabel(self)
0+        self.label.setText(QString("This is a second window in the stack"))
0+        self.setCentralWidget(self.label)
0+
0+if __name__ == '__main__':
0+    app = QApplication(sys.argv)
0+    sw = StackedWindow()
0+    sw.show()
0+    sys.exit(app.exec_())
...
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
--- Revision None
+++ Revision 313661333563
@@ -0,0 +1,41 @@
+# Author: Tomi Saarinen, Rohea Oy
+# License: Do what you feel like but we guarantee nothing.
+import sys
+from PySide.QtCore import *
+from PySide.QtGui import *
+
+class StackedWindow(QMainWindow):
+ def __init__(self):
+ QMainWindow.__init__(self)
+ # This attribute makes the whole Stacked Window thing work
+ self.setAttribute(Qt.WA_Maemo5StackedWindow)
+ # Create button and layout
+ self.cw = QWidget(self)
+ self.setCentralWidget(self.cw)
+ self.vbox = QVBoxLayout(self.cw)
+ self.button = QPushButton(self)
+ self.button.setText(QString("Push me"))
+ self.vbox.addWidget(self.button)
+ # Create subwindow
+ self.subWindow = SubWindow(self)
+ # Hide subwindow at first
+ self.subWindow.hide()
+ # Connect button to signal
+ self.connect(self.button, SIGNAL("clicked()"), self.subWindow.show)
+
+class SubWindow(QMainWindow):
+ def __init__(self, parent):
+ # Notice that you must give a parent window as parameter to the constuctor
+ QMainWindow.__init__(self, parent)
+ # Also set the Stacked Window parameter for every subwindow in the stack
+ self.setAttribute(Qt.WA_Maemo5StackedWindow)
+ # Just some content...
+ self.label = QLabel(self)
+ self.label.setText(QString("This is a second window in the stack"))
+ self.setCentralWidget(self.label)
+
+if __name__ == '__main__':
+ app = QApplication(sys.argv)
+ sw = StackedWindow()
+ sw.show()
+ sys.exit(app.exec_())