Y
Y
y_o_l_k_i_n___e_g_o_r2021-04-28 11:31:26
Python
y_o_l_k_i_n___e_g_o_r, 2021-04-28 11:31:26

QScrollArea doesn't work. What to do?

When creating a ScrollArea, just a gray
60891c07ddac7952552522.jpeg

main.py window:

from PyQt5 import QtWidgets
from notes import Ui_Main_Window


class Win(QtWidgets.QMainWindow):
    def __init__(self):
        global user
        super().__init__()
        self.ui = Ui_MainWindow()
        self.ui.setupUi(self)
        #   create ScrollArea
        sa = QtWidgets.QScrollArea()
        sa.resize(200, 200)
        sa.setWidget(self.ui.tabWidget)


app = QtWidgets.QApplication([])
appl = Win()
appl.show()

exit(app.exec())


notes.py (design):

from PyQt5 import QtCore, QtGui, QtWidgets


class Ui_MainWindow(object):
    def setupUi(self, MainWindow):
        MainWindow.setObjectName("MainWindow")
        MainWindow.resize(291, 440)
        MainWindow.setStyleSheet("background: rgb(50, 50, 50);")
        self.centralwidget = QtWidgets.QWidget(MainWindow)
        self.centralwidget.setObjectName("centralwidget")
        self.tabWidget = QtWidgets.QTabWidget(self.centralwidget)
        self.tabWidget.setGeometry(QtCore.QRect(0, 0, 291, 441))
        self.tabWidget.setStyleSheet("QTabBar::tab{\n"
"    border-radius: 10px;\n"
"    margin: 5px;\n"
"    padding: 10px;\n"
"    background: white;\n"
"}\n"
"QTabBar::tab::selected {\n"
"    background: orange;\n"
"    color: white;\n"
"}")
        self.tabWidget.setObjectName("tabWidget")
        self.notes = QtWidgets.QWidget()
        self.notes.setObjectName("notes")
        self.label_4 = QtWidgets.QLabel(self.notes)
        self.label_4.setGeometry(QtCore.QRect(10, 10, 261, 111))
        self.label_4.setStyleSheet("border: 1px solid white;\n"
"color: white;\n"
"font-size: 15px;")
        self.label_4.setAlignment(QtCore.Qt.AlignLeading|QtCore.Qt.AlignLeft|QtCore.Qt.AlignTop)
        self.label_4.setObjectName("label_4")
        self.label_5 = QtWidgets.QLabel(self.notes)
        self.label_5.setGeometry(QtCore.QRect(10, 140, 261, 111))
        self.label_5.setStyleSheet("border: 1px solid white;\n"
"color: white;\n"
"font-size: 15px;")
        self.label_5.setAlignment(QtCore.Qt.AlignLeading|QtCore.Qt.AlignLeft|QtCore.Qt.AlignTop)
        self.label_5.setObjectName("label_5")
        self.label_6 = QtWidgets.QLabel(self.notes)
        self.label_6.setGeometry(QtCore.QRect(10, 270, 261, 111))
        self.label_6.setStyleSheet("border: 1px solid white;\n"
"color: white;\n"
"font-size: 15px;")
        self.label_6.setAlignment(QtCore.Qt.AlignLeading|QtCore.Qt.AlignLeft|QtCore.Qt.AlignTop)
        self.label_6.setObjectName("label_6")
        self.tabWidget.addTab(self.notes, "")
        self.add_notes = QtWidgets.QWidget()
        self.add_notes.setObjectName("add_notes")
        self.pushButton = QtWidgets.QPushButton(self.add_notes)
        self.pushButton.setGeometry(QtCore.QRect(80, 340, 121, 31))
        self.pushButton.setStyleSheet("QPushButton {\n"
"background: black;\n"
"color: white;\n"
"border:1px solid white;\n"
"border-radius: 10px;\n"
"}")
        self.pushButton.setObjectName("pushButton")
        self.lineEdit = QtWidgets.QLineEdit(self.add_notes)
        self.lineEdit.setGeometry(QtCore.QRect(40, 80, 201, 41))
        self.lineEdit.setStyleSheet("background: black;\n"
"color: white;\n"
"border:1px solid white;\n"
"border-radius: 10px;")
        self.lineEdit.setObjectName("lineEdit")
        self.label = QtWidgets.QLabel(self.add_notes)
        self.label.setGeometry(QtCore.QRect(50, 60, 71, 16))
        self.label.setStyleSheet("color: white;")
        self.label.setObjectName("label")
        self.label_2 = QtWidgets.QLabel(self.add_notes)
        self.label_2.setGeometry(QtCore.QRect(30, 10, 211, 31))
        self.label_2.setLayoutDirection(QtCore.Qt.LeftToRight)
        self.label_2.setStyleSheet("color: white;\n"
"font-size: 20px;")
        self.label_2.setLineWidth(0)
        self.label_2.setMidLineWidth(0)
        self.label_2.setAlignment(QtCore.Qt.AlignCenter)
        self.label_2.setObjectName("label_2")
        self.label_3 = QtWidgets.QLabel(self.add_notes)
        self.label_3.setGeometry(QtCore.QRect(50, 140, 101, 16))
        self.label_3.setStyleSheet("color: white;")
        self.label_3.setObjectName("label_3")
        self.lineEdit_2 = QtWidgets.QLineEdit(self.add_notes)
        self.lineEdit_2.setGeometry(QtCore.QRect(40, 160, 201, 141))
        self.lineEdit_2.setStyleSheet("background: black;\n"
"color: white;\n"
"border:1px solid white;\n"
"border-radius: 10px;")
        self.lineEdit_2.setText("")
        self.lineEdit_2.setAlignment(QtCore.Qt.AlignLeading|QtCore.Qt.AlignLeft|QtCore.Qt.AlignTop)
        self.lineEdit_2.setObjectName("lineEdit_2")
        self.tabWidget.addTab(self.add_notes, "")
        MainWindow.setCentralWidget(self.centralwidget)

        self.retranslateUi(MainWindow)
        self.tabWidget.setCurrentIndex(0)
        QtCore.QMetaObject.connectSlotsByName(MainWindow)

    def retranslateUi(self, MainWindow):
        _translate = QtCore.QCoreApplication.translate
        MainWindow.setWindowTitle(_translate("MainWindow", "MainWindow"))
        self.label_4.setText(_translate("MainWindow", "Сварить суп"))
        self.label_5.setText(_translate("MainWindow", "Сделать ещё что-то"))
        self.label_6.setText(_translate("MainWindow", "И ещё что-то..."))
        self.tabWidget.setTabText(self.tabWidget.indexOf(self.notes), _translate("MainWindow", "Заметки"))
        self.pushButton.setText(_translate("MainWindow", "Сохранить"))
        self.label.setText(_translate("MainWindow", "Заголовок:"))
        self.label_2.setText(_translate("MainWindow", "Создание заметки"))
        self.label_3.setText(_translate("MainWindow", "Текст заметки:"))
        self.tabWidget.setTabText(self.tabWidget.indexOf(self.add_notes), _translate("MainWindow", "Добавить заметку"))


How to make notes scroll?
60891d5bd2598226795459.jpeg

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question