Answer the question
In order to leave comments, you need to log in
Added a widget, but it didn't show up when I started the program (PyQt5). What have I done wrong?
I created a class that calls an additional window. When you add widgets to it and then compile them, they are not displayed. I can't understand the reason.
I started learning PyQt a month ago.
This is the empty window I see
import sys
from MainWindow import *
from PyQt5 import QtCore, QtGui, QtWidgets
class Cost_Actives(QtWidgets.QWidget):
def __init__(self, parent=None):
super().__init__(parent, QtCore.Qt.Window)
self.build()
def build(self):
self.qle = QtWidgets.QTextEdit()
class MyWin(QtWidgets.QMainWindow):
def __init__(self, parent=None):
QtWidgets.QWidget.__init__(self, parent)
self.ui= Ui_MainWindow()
self.ui.setupUi(self)
self.ui.pushButton.clicked.connect(self.CostA)
def CostA(self):
self.secondWin = Cost_Actives(self)
self.secondWin.show()
if __name__=="__main__":
app = QtWidgets.QApplication(sys.argv)
myapp = MyWin()
myapp.show()
sys.exit(app.exec_())
Answer the question
In order to leave comments, you need to log in
Did you specify what and where to draw?
def build(self):
# self.qle = QtWidgets.QTextEdit() # Создание атрибута класса и запись туда QTextEdit (и все)
self.qle = QtWidgets.QTextEdit(self) # передайте родителя!
class Cost_Actives(QtWidgets.QWidget):
def __init__(self, parent=None):
super().__init__(parent, QtCore.Qt.Window)
self.ui = Ui_Form()
self.ui.setupUi(self)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question