Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt
  • Unsolved
Collapse
qtws26_logo

The Qt Event of the Year: Qt World Summit 2026

Save Your Spot >
Brand Logo
  1. Home
  2. Qt Development
  3. Qt for Python
  4. Problem with Main Window
Qt 6.12 LTS is out! See what's new in the release blog

Problem with Main Window

Scheduled Pinned Locked Moved Solved Qt for Python
4 Posts 2 Posters 941 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    Achab61
    wrote on last edited by
    #1

    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.show

    app=qtw.QApplication([])
    window = qtw.QWidget()
    window.show
    mw=MainWindow()

    app.exec_()

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      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).

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      1
      • A Offline
        A Offline
        Achab61
        wrote on last edited by
        #3

        Thank you very much !

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          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 :-)

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt
          • Unsolved