Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. CSS, QSlider, set background, handle not visible anymore
Forum Updated to NodeBB v4.3 + New Features

CSS, QSlider, set background, handle not visible anymore

Scheduled Pinned Locked Moved General and Desktop
2 Posts 2 Posters 2.8k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    dustije
    wrote on last edited by
    #1

    Hi,

    i have the following code:
    @CustomSlider::CustomSlider(QWidget *parent) :
    QSlider(parent)
    {
    QObject::connect(this, SIGNAL(sliderMoved(int)), this, SLOT(valueChanged(int)));
    }

    void CustomSlider::valueChanged(int value)
    {
    int c = (int)(2.55*value);
    QString stylesheet = "QSlider::groove:horizontal { background: rgba(" + QString::number(c) + ", 0, 0, " + QString::number(c) + ");}";
    this->setStyleSheet(stylesheet);
    }@

    I want the slider to change the background color depending on the current value of the slider. The higher the value, the more red i want the background to be. The color changing effect works, except the handle is not visible anymore. This makes no sense to me, because i really just set the background of the slider, which should not effect the handle or the visibility of the handle.
    I think i miss something essential but i can't figure out what. I have no idea why setting the background color of a slider changes the handle to not visible.
    Can someone give me some hints why this is happening and how i can avoid it? Thanks in advance!

    1 Reply Last reply
    0
    • B Offline
      B Offline
      b1gsnak3
      wrote on last edited by
      #2

      when you modify your css for a widget consisting of multiple elements you must define css for every item otherwise the other items will be set to default (sometimes hidden)

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved