Revision 313661333563 () - Diff

Link to this snippet: https://friendpaste.com/3ShZGYNMUJQTYHf0lV9LI0
Embed:
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
# 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_())