I made an interface using Qt designer and saved it in a file main.ui
So, i've tried 2 ways to show my window using python and both returned an empty window:
First attempt (using the main.ui directly):
from PySide.QtGui import *
from PySide.QtCore import *
from PySide import QtUiTools
class MainApp(QMainWindow):
def init(self, *args):
apply(QMainWindow.__init__,(self,) + args)
loader = QtUiTools.QUiLoader()
file = QFile("main.ui")
file.open(QFile.ReadOnly)
self.myWidget = loader.load(file, self)
file.close()
self.setCentralWidget(self.myWidget)
if __name__ == '__main__':
import sys
import os
print "Running in %s.\n" % os.getcwd()
app = QApplication(sys.argv)
window = MainApp()
window.show()
app.connect(app, SIGNAL("lastWindowClosed()"),
app, SLOT("quit()")
)
app.exec_()
For the second attempt, I used Pyside-uic.exe to generate a main.py file:
from PySide.QtGui import *
from PySide.QtCore import *
from qt_gui.main import *
import sys
class MainApp(QtGui.QMainWindow, Ui_MainWindow):
def init(self, parent = None):
super(MainApp, self).__init__(parent)
self.setupUi(self)
if __name__ == '__main__':
app = QtGui.QApplication(sys.argv)
window = MainApp()
window.show()
sys.exit(app.exec_())
I've saw a lot of examples doing the same but none worked for me.