AttributeError: QDialog object has no attribute setCentralWidget

后端 未结 2 1127
被撕碎了的回忆
被撕碎了的回忆 2021-01-14 12:55

I\'m trying to create a GUI with QT Designer. I\'ve converted my .ui designer file to a .py file using the following tutorial: http://pyqt.sourceforge.net/Docs/PyQt5/designe

2条回答
  •  孤独总比滥情好
    2021-01-14 13:41

    Instead of going all the way to QtDesigner and make another ui You can go to the ui file and edit it in the Code editor and you will see that the file has the main class written in the first or second line and you can change it Here is an example.

    
    
     Form
     
      
      .
      .
      .
      .
    

    Here we can change the tag's class attribute to QMainWindow so it will become

    
    
     Form
     
      
       .
       .
       .
       .
    

提交回复
热议问题