The problem is that inside initUi
you make another QWidget
, set it to full screen, show it, and then when that widget goes out of scope it gets garbage collected and disappears. You meant to use self
instead of making a new QWidget
. Like this:
import sys
from PyQt4 import QtGui, QtCore
class mainUI(QtGui.QWidget):
def __init__(self):
super(mainUI, self).__init__()
self.initUI()
def initUI(self):
self.showFullScreen()
qbtn = QtGui.QPushButton('Quit')
qbtn.clicked.connect(QtCore.QCoreApplication.quit)
qbtn.move(5,5)
self.button = qbtn
qbtn.show()
def main():
app = QtGui.QApplication(sys.argv)
window = mainUI()
sys.exit(app.exec_())
if __name__ == '__main__':
main()
Note that I keep a reference to qbtn
so that it doesn't get garbage collected and disappear.