0

Good afternoon, I have this code which creates the basic layout of the page and fills it with the necessary widgets. This code is compiled from Qt designer.

class Ui_MainWindow(object):
def setupUi(self, MainWindow):
    MainWindow.setObjectName("MainWindow")
    MainWindow.setWindowModality(QtCore.Qt.NonModal)
    MainWindow.setEnabled(True)
    MainWindow.resize(800, 800)
    MainWindow.setFocusPolicy(QtCore.Qt.NoFocus)
    MainWindow.setAutoFillBackground(False)
    MainWindow.setStyleSheet("background-color: rgb(135, 145, 151);")
    MainWindow.setDocumentMode(False)


    self.centralwidget = QtWidgets.QWidget(MainWindow)
    self.centralwidget.setObjectName("centralwidget")

    self.gridLayout = QtWidgets.QGridLayout(self.centralwidget)
    self.gridLayout.setObjectName("gridLayout")

    self.person_title = QtWidgets.QTextEdit(self.centralwidget)
    self.person_title.setFixedHeight(35)
    self.person_title.setStyleSheet("color: rgb(255, 255, 255);\n"
                                    "")
    self.person_title.setInputMethodHints(QtCore.Qt.ImhNone)
    self.person_title.setObjectName("person_title")
    self.gridLayout.addWidget(self.person_title, 2, 0, 1, 1)


    self.widget = QtWidgets.QWidget(self.centralwidget)
    self.widget.setStyleSheet("")
    self.widget.setObjectName("widget")
    self.formLayout = QtWidgets.QFormLayout(self.widget)
    self.widget.setFixedHeight(400)
    self.formLayout.setObjectName("formLayout")
    self.add_fields(self.widget.objectName())
    self.widget_z = 3
    self.gridLayout.addWidget(self.widget, self.widget_z, 0, 1, 1)

And e.t.c. Then there is code that adds on the button again the widget.

    def form_add(self):
        self.widget = QtWidgets.QWidget(self.centralwidget)
        self.widget.setStyleSheet("")
        self.widget.setFixedHeight(400)
        self.formLayout = QtWidgets.QFormLayout(self.widget)
        self.formLayout.setObjectName("formLayout")
        self.add_fields(self.widget)
        self.count = 0
        self.count += 1
        self.widget_z += 1
        self.widget.setObjectName(f"widget{self.count}")
        self.widget.show()
        self.gridLayout.addWidget(self.widget, self.widget_z, 0, 1, 1)

Also implemented the function of collecting information from these forms. Unfortunately, when 2+ forms are added, they are no longer visible. Tried to make a vertical scrollbar, but found nowhere to implement it in my type.

Can you please tell me how to implement a scrolling function in this loyaut, so that I could move around the page and fill out all of the added forms?

Mary
  • 1

0 Answers0