Problem with Main Window
-
Hi all,
I'm learning QT (PyQt5_Qt5-5.15.2) with Python (3.9.10) and I have the following problem with this code as it does not display any window. Any help is welcome. Thanks !
import PyQt5.QtWidgets as qtw
import sys
class MainWindow(qtw.QWidget):
def init(self):
super().init()
self.setWindowTitle("Hello World!!")
self.showapp=qtw.QApplication([])
window = qtw.QWidget()
window.show
mw=MainWindow()app.exec_()
-
Hi and welcome to devnet,
You forgot the parenthesis in your show calls.
On a side note, don't call show in your
__init__
method. It's not the role of the widget to show itself.For your next post, please use coding tags to make it readable (the </> button in the editor or tree back ticks before and after your code).
-
You're welcome !
Since you have it working now, please mark the thread as solved using the "Topic Tools" button or the three dotted menu beside the answer you deem correct so that other forum users may know solution has been found :-)