Answer the question
In order to leave comments, you need to log in
QWidget: Must construct a QApplication before a QWidget?
main file:
import login
dialog = login.login_dialog()
dialog.exec()
from PyQt5 import QtCore, QtGui, QtWidgets
class login_dialog(QtWidgets.QDialog):
def __init__(self,parent=None):
super(login_dialog, self).__init__(parent)
self.setObjectName("Dialog")
self.resize(400, 300)
#и так далее
QWidget: Must construct a QApplication before a QWidget
Answer the question
In order to leave comments, you need to log in
Well, everything is written correctly. You are not creating an instance of the QApplication class anywhere, to which all widgets should cling.
Google hello world on PyQT5 , it would immediately become clear.
from PyQt5.QtWidgets import QApplication, QLabel
app = QApplication([])
# This is a requirement of Qt: Every GUI app must have exactly one instance of QApplication.
# Many parts of Qt don't work until you have executed the above line.
# You will therefore need it in virtually every (Py)Qt app you write.
# The brackets [] in the above line represent the command line arguments passed to the application.
# Because our app doesn't use any parameters, we leave the brackets empty.
label = QLabel('Hello World!')
label.show()
app.exec()
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question