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. Resizable Slider widget aka Range Indicator

Resizable Slider widget aka Range Indicator

Scheduled Pinned Locked Moved General and Desktop
1 Posts 1 Posters 2.5k 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.
  • S Offline
    S Offline
    soroush
    wrote on last edited by
    #1

    I want a widget to specify a date range. It should look like a slider with two handles.
    I know there is QxtSpanSlider but it does not fit in my requirements. What I need is a slider with two handles and a scroll handle between them. Area between two handles should be colored. Scroll handle should take a constant percent of space (say 60%) unless handles are too close . In that case, scroll handle should not be shown.
    The widget looks like this (on Ubuntu / KDE / Oxygen theme) (GIMPed of course):

    !http://s2.picofile.com/file/7911319886/s6.png(s)!

    What I've tried so far is a class derived from QSlider that re-implements paintEvent:
    @
    void ScrollScaler::paintEvent(QPaintEvent *e)
    {
    QStylePainter painter(this);
    QStyleOptionSlider opt;
    QStyleOptionSlider opt2;
    initStyleOption(&opt);
    initStyleOption(&opt2);
    opt.initFrom(this);
    opt2.initFrom(this);
    //opt.dialWrapping = false;
    opt.sliderValue = 50;
    opt.sliderPosition = 50;
    opt.orientation = Qt::Vertical;
    opt.subControls = QStyle::SC_SliderGroove | QStyle::SC_SliderTickmarks ;
    opt2.sliderPosition = 20;
    opt2.subControls = QStyle::SC_SliderHandle;
    // opt.rect = this->rect();
    painter.drawComplexControl(QStyle::CC_Slider, opt);
    painter.drawComplexControl(QStyle::CC_Slider, opt2);
    opt2.sliderPosition = 80;
    painter.drawComplexControl(QStyle::CC_Slider, opt2);
    // Trying to draw scroll handle:
    QStyleOptionComplex soc;
    soc.subControls = QStyle::SC_ScrollBarSlider;
    soc.initFrom(this);
    painter.drawComplexControl(QStyle::CC_ScrollBar, soc);
    e->accept();
    }
    @

    I have a couple of problems:

    1. When orientation is horizontal, widget looks weird:
      !http://s3.picofile.com/file/7911329137/s66.png(Vertical)!
      !http://s1.picofile.com/file/7911327197/s7.png(Horizontal)!
    2. I don't know how to add scroll handle

    Any help to drawing widget and/or adding functionality is appropriate

    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