heidz
heidz

Reputation: 9

problem with loading the qt designer ui file using PySide6

Hi am a beginner in programming and just getting started with the PySide library. So I made this ui using the qt designer, and used the following code to run it.

import sys
from PySide6 import QtCore as qtc
from PySide6 import QtWidgets as qtw
from PySide6 import QtGui as qtg

from mainui_ui import Ui_MainWindow

class mainscreen(qtw.QWidget, Ui_MainWindow):
    def __init__(self):
        super().__init__()
        self.setupUi(self)
        
        
if __name__ == "__main__":
    app = qtw.QApplication(sys.argv)
    
    window = mainscreen()
    window.show()
    
    sys.exit(app.exec)
    

but i am getting the following error:

Traceback (most recent call last):
  File "d:\College\project stock mangement\code\new\homescreen.py", line 17, in <module>
    window = mainscreen()
  File "d:\College\project stock mangement\code\new\homescreen.py", line 11, in __init__
    self.setupUi(self)
    ~~~~~~~~~~~~^^^^^^
  File "d:\College\project stock mangement\code\new\mainui_ui.py", line 87, in setupUi
    MainWindow.setCentralWidget(self.centralwidget)
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'mainscreen' object has no attribute 'setCentralWidget'. Did you mean: 'centralwidget'?

I tried changing the following line of code class mainscreen(qtw.QWidget, Ui_MainWindow): to QMainwindow instead of the Qwidget but then the application doesnt run. Can anyone help with this .

i expected something like this to pop up: enter image description here

Upvotes: 0

Views: 39

Answers (0)

Related Questions