I want to create a GUI for a python file I wrote, so I downloaded PyQt5 and Qt Designer. When I exported my first try of the Qt Designer project I realized that the not PyQt5 was used but PySide2. What is the reason for this?
Till then everything worked fine, and I wanted to start some specific things like bringing a widget I created into a scrollArea. For this I created a custom widget and created a .ui and a .py. But they don't show up if I try to call them. Also the generated code for python looks like this:
from PySide2.QtCore import (QCoreApplication, QMetaObject, QObject, QPoint, QRect, QSize, QUrl, Qt)
from PySide2.QtGui import (QBrush, QColor, QConicalGradient, QCursor, QFont, QFontDatabase, QIcon, QLinearGradient, QPalette, QPainter, QPixmap, QRadialGradient)
from PySide2.QtWidgets import *
class Ui_Form(object):
def setupUi(self, Form):
if Form.objectName():
Form.setObjectName(u"Form")
Form.resize(640, 480)
self.widget = QWidget(Form)
self.widget.setObjectName(u"widget")
self.widget.setGeometry(QRect(270, 190, 77, 44))
self.verticalLayout = QVBoxLayout(self.widget)
self.verticalLayout.setObjectName(u"verticalLayout")
self.verticalLayout.setContentsMargins(0, 0, 0, 0)
self.label = QLabel(self.widget)
self.label.setObjectName(u"label")
self.verticalLayout.addWidget(self.label)
self.pushButton = QPushButton(self.widget)
self.pushButton.setObjectName(u"pushButton")
self.verticalLayout.addWidget(self.pushButton)
self.retranslateUi(Form)
QMetaObject.connectSlotsByName(Form)
# setupUi
def retranslateUi(self, Form):
Form.setWindowTitle(QCoreApplication.translate("Form", u"Form", None))
self.label.setText(QCoreApplication.translate("Form", u"TextLabel", None))
self.pushButton.setText(QCoreApplication.translate("Form", u"PushButton", None))
# retranslateUi
As you can see, my widget does not inherit from "QWidget" but from "object". Also, my widget has no "init" but a "setupUi". Why is that?
If I change to inherit from "object" to "QWidget" the code runs bot the widget does not show up. Also, when I try to show only the widget itself with the following code, it does not show up.
if __name__ == "__main__":
import sys
app = QApplication(sys.argv)
w = Ui_Form()
w.show()
sys.exit(app.exec_())
Empty Widget
I tried to search around and did not find anything that helped me out, so I'm asking my questions here.
Can somebody please explain to me why all this is happening like it is right now and how I can make them widgets show up and add them to a scrollArea?
Thanks in advance!