Results 1 to 8 of 8

Thread: Rotating a slider...

  1. #1

    Default Rotating a slider...

    Hi there.
    I've never used Qt before, but am about ready to jump in for a project at work.
    On thing we're looking for is a slider widget that we can rotate 45 degrees.
    Is something like that possible? If so, what would be the best way to go about it?

    Thanks,

    Alec

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,018 Times in 4,794 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Rotating a slider...

    You can't have it out of the box. You'd have to subclass the slider and reimplement its event handlers (at least paint, mousePress, mouseMove and mouseRelease). In the reimplementation you'd have to recalculate cursor positions and call the base class handlers with the modified events.

  3. #3
    Join Date
    Aug 2006
    Location
    Bangalore,India
    Posts
    419
    Thanks
    37
    Thanked 53 Times in 40 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: Rotating a slider...

    Quote Originally Posted by ACFred View Post
    Hi there.
    I've never used Qt before, but am about ready to jump in for a project at work.
    On thing we're looking for is a slider widget that we can rotate 45 degrees.
    Is something like that possible? If so, what would be the best way to go about it?

    Thanks,

    Alec
    If you can use qt-4.4 , you can probably try QGraphicsWidget class to embed a slider in QGraphicsView as a QGraphicsItem. This allows you to have anykind of transformation on your slider.
    Have a look at
    http://labs.trolltech.com/blogs/2007...as-integrated/
    The biggest difference between time and space is that you can't reuse time.
    -- Merrick Furst

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,018 Times in 4,794 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Rotating a slider...

    Currently I managed to do something like this using the approach I suggested. It's not perfect - not all events are propagated by my proxy to the slider and vice versa.
    Attached Images Attached Images

  5. #5
    Join Date
    Aug 2006
    Location
    Bangalore,India
    Posts
    419
    Thanks
    37
    Thanked 53 Times in 40 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: Rotating a slider...

    Did you reimplement the slider and paint the rotated one using QWidget::render() ? Or are you using QStyle to draw the controls ?
    The biggest difference between time and space is that you can't reuse time.
    -- Merrick Furst

  6. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,018 Times in 4,794 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Rotating a slider...

    Quote Originally Posted by Gopala Krishna View Post
    Did you reimplement the slider and paint the rotated one using QWidget::render() ? Or are you using QStyle to draw the controls ?
    I didn't touch the slider. I implemented a proxy widget for transforming other widgets similar to the widget proxy from the graphics view that allows arbitrary transformations of widgets.
    Attached Images Attached Images

  7. #7
    Join Date
    Aug 2006
    Location
    Bangalore,India
    Posts
    419
    Thanks
    37
    Thanked 53 Times in 40 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: Rotating a slider...

    Ok nice approach. Is the widget's geometry still rectangular(globally) after rotating the hosted widget ?
    Have you done masking also ?
    The biggest difference between time and space is that you can't reuse time.
    -- Merrick Furst

  8. #8
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,018 Times in 4,794 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Rotating a slider...

    Quote Originally Posted by Gopala Krishna View Post
    Is the widget's geometry still rectangular(globally) after rotating the hosted widget ?
    Yes.
    Have you done masking also ?
    No, there is no need for that - widgets are transparent by default, so no masking is needed for transparency and if you want a non-rectangular widget, you have to do the same as for other widgets - mask them yourself (all widgets are rectangular by default). Masking is expensive, so it's better to avoid it if possible.

Similar Threads

  1. slider control and combo box in grid view
    By steg90 in forum Qt Programming
    Replies: 13
    Last Post: 21st November 2007, 10:45
  2. custom slider question (very advanced)
    By MarkoSan in forum Qt Programming
    Replies: 17
    Last Post: 21st November 2007, 08:19
  3. get slider value
    By eric in forum Qt Programming
    Replies: 1
    Last Post: 8th November 2007, 19:47
  4. line edit value change with slider
    By jjbabu in forum Qt Tools
    Replies: 1
    Last Post: 22nd September 2007, 07:02
  5. Tick Labels for Slider
    By jcraig in forum Qt Tools
    Replies: 2
    Last Post: 9th August 2007, 17:21

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.