agile
agile

Reputation: 77

What is the difference between using QMainWindow from importing and the use of uic.loadUiType?

Both of the following codes are codes that show empty gui. But the code above is QMainWindow From PyQt5.QtWidgets import QApplication, QMainWindow Use this and the code below is uic.loadUiType. If you look on the Internet, you can't see the difference between the two codes, some using the above and some using the below code. I ask you to explain about this.

#---------------------------upside code------------------------#
import sys
from PyQt5.QtWidgets import QApplication
from PyQt5 import uic

[form_class,QMainWindow]=uic.loadUiType('uifile.ui')

class Main(form_class,QMainWindow):

    def __init__(self):
        super().__init__()
        self.setupUi(self)

if __name__ == '__main__':
    app = QApplication(sys.argv)
    main = Main()
    main.show()
    app.exec()


#---------------------------downside code------------------------#
import sys
from PyQt5.QtWidgets import QApplication, QMainWindow
from PyQt5 import uic

form_class=uic.loadUiType('uifile.ui')[0]

class Main(form_class,QMainWindow):

    def __init__(self):
        super().__init__()
        self.setupUi(self)

if __name__ == '__main__':
    app = QApplication(sys.argv)
    main = Main()
    main.show()
    app.exec()

Upvotes: 0

Views: 81

Answers (0)

Related Questions