0

my code

import sys
import os 
from PyQt5.QtWidgets import *
from PyQt5.QtCore import *
from PyQt5.QtGui import *

class Window(QWidget):
    def __init__(self):
        super().__init__()
        self.resize(800, 800)
        self.setStyleSheet('background:red;')

        wid = QWidget(self)
        lay = QVBoxLayout(wid)

        up = QWidget(wid)
        up.setStyleSheet('background:gray;')
        lay.addWidget(up)
        lay_up = QVBoxLayout(up)

        self.rad = QRadioButton(up)
        self.rad.setStyleSheet('background:blue;')
        lay_up.addWidget(self.rad)

        self.area = QScrollArea(wid)
        self.area.setStyleSheet('''
        QScrollArea  {
            border:none;
        }''')
        lay.addWidget(self.area)


        self.content = QWidget()

        self.area.setWidgetResizable(True)
        self.area.setWidget(self.content)


        lay_content = QVBoxLayout(self.content)

        label = QLabel(self.content)
        label.setText('test')
        label.setStyleSheet('background:green;padding:30')

        lay_content.addWidget(label)

        self.area.setAlignment(Qt.AlignTop | Qt.AlignLeft)

        self.rad.pressed.connect(self.on_pressed)

        self.menuAnimation = QVariantAnimation() 
        self.menuAnimation.setDuration(8000)  

        self.menuAnimation.valueChanged.connect(self.value_can)
        self.menuAnimation.setStartValue(self.content.sizeHint().height())
        self.menuAnimation.setEndValue(0)

    def on_pressed(self):
        self.menuAnimation.start()

    def value_can(self, value) :
        self.area.setMaximumHeight(value)

if __name__ == '__main__':
    app = QApplication(sys.argv)
    w = Window()
    w.show()
    sys.exit(app.exec_())

I need after clicking the radio the widget was hiding but without scrollbars.

How do I hide them?

I tried to find properties in qss

but I found only QScrollBar and it does not work for QScrollArea.

I tried to hide it with the help of the border:none,

but when I click on the button the scroll box reappears.

eyllanesc
  • 235,170
  • 19
  • 170
  • 241
askqest
  • 47
  • 2
  • 9
  • @eyllanesc but I don’t know how to translate from C to python – askqest Apr 03 '20 at 14:57
  • It is not necessary to translate anything since it is only necessary to know the names of the functions to use it in python: https://stackoverflow.com/a/3384513/6622587 ---> `self.area.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff)` `self.area.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)` – eyllanesc Apr 03 '20 at 14:59

0 Answers0