# 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_())