Quantcast
Viewing all articles
Browse latest Browse all 14069

PySide6 QUiLoader doesn't show window

It is a simple coding.I tried the code below which is almost same example in the QT for Python website.

see the website below option B.

https://doc.qt.io/qtforpython-6/tutorials/basictutorial/uifiles.html

but when I execute the code below, it doesn't show the window and keep running until I stop.I put print codes in the code to figure out where it is and it is loader = QUiLoader().print('d') is not executed.

No error messeges. It is just keep running without showing window.

ui file is okay. I converted .ui file to .py file and it works well. also when I clicked ui file, it shows Qt design well.

import sysfrom PySide6.QtUiTools import QUiLoaderfrom PySide6.QtWidgets import QApplicationfrom PySide6.QtCore import QFile, QIODeviceprint('a')app = QApplication(sys.argv)ui_file_name = 'imported_from_design.ui'ui_file = QFile(ui_file_name)print('b')if not ui_file.open(QIODevice.ReadOnly):    print("Can not open the file {}, the error is {}".format(ui_file_name, ui_file.errorString()))    sys.exit(-1)print('c')loader = QUiLoader()print('d')window = loader.load(ui_file)ui_file.close()if not window:    print(loader.errorString())    sys.exit(-1)window.show()sys.exit(app.exec())print('e')

Viewing all articles
Browse latest Browse all 14069

Trending Articles