1

I want to set transparent background or borders for QWidget which is under QScrollArea and contains sets of buttons and labels.

When I added a QScrollArea to my QMainWidow it has overridden backgroud for this area that has been already active (gradient). In return I encountered default Fusion style background.

I tried to set different style for QWidget that's inside of QScrollArea. I want to mention that when I tried to set transparency, so called 'transparency' was just a fading to default Fusion style.

At this point I ended with rectangle box (QScrollArea) with gradient color. I tried to beautify it with border-radius and again I encountered just a white background where should be a trasparent area.

enter image description here

class MainMenu(QtWidgets.QMainWindow):
    def __init__(self, playflash):
        QtWidgets.QMainWindow.__init__(self)

        # [...]

        self.widget_panel.setProperty("class", "qwidget-special")
        self.special_style = """
                .qwidget-special
                {
                    background: qlineargradient(spread:pad, x1:0.505, y1:0.0797273, x2:0.51, y2:0.920455, stop:0 rgba(112, 98, 174, 255), stop:1 rgba(224, 205, 255, 255));
                    border-radius: 18px; border-color: transparent;
                }
                """
        self.widget_panel.setStyleSheet(self.special_style)

        # [...]

Layout tree:

  • MainMenu (QMainWindow)
    • centalwidget (QWidget):
      • scroll_panel (QScrollArea)
        • widget_panel (QWidget)
          • buttons and labels

I try to achive a background (QWidget) with border-radius without a white background just filled with gradient.

1
  • Your question is unclear, please try to better explain what you want to achieve, possibly with a mock-up of the wanted result. Commented Jun 13, 2022 at 9:43

0

Browse other questions tagged or ask your own question.