Skip to content

QLabeledRangeSlider/QRangeSlider does not work properly with parent widget background #201

Description

@hrimov

Describe the bug
QLabeledRangeSlider (as well as QRangeSlider) does not work properly with parent widget background. Parent background hovers minimal handle and all the bar-range. I've tested with PyQt6.QtWidgets.QSlider, it works fine with background.

To Reproduce
Steps to reproduce the behavior:

  1. Create PyQt application instance and main widget with layout (QVBoxLayout e.g.).
  2. Create QRangeSlider/QLabeledRangeSlider, add values and range.
  3. Set stylesheet for main widget with background: black;.
  4. See that Slider does not have minimal handle and bar (for labeled Slider labels will be present, figured it out with another background color.

Example code:

import sys
from PyQt6 import QtWidgets, QtCore
from superqt import QLabeledRangeSlider, QRangeSlider
app = QtWidgets.QApplication([])
main_widget = QtWidgets.QWidget()
# main_widget.setStyleSheet("background: black;")
range_slider = QLabeledRangeSlider(QtCore.Qt.Orientation.Horizontal)
range_slider.setValue((15, 25))
range_slider.setRange(10, 40)
lay = QtWidgets.QVBoxLayout()
main_widget.setLayout(lay)
lay.addWidget(range_slider)
main_widget.setMinimumSize(600, 400)
main_widget.show()
sys.exit(app.exec())

Expected behavior
It was expected that the parent widget background would not affect the child widget.

Screenshots
QLabeledRangeSlider without parent widget background
Screenshot 2023-09-12 at 21 16 43
QLabeledRangeSlider with parent widget background
Screenshot 2023-09-12 at 21 16 14

Desktop (please complete the following information):

  • macOS 12.2.1, Apple M1 chip
  • PyQt6 (6.5.1)
  • Python 3.10.10

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions