Results 1 to 4 of 4

Thread: Setting colour on qslider

  1. #1
    Join Date
    Apr 2011
    Location
    Hyderabad
    Posts
    86
    Thanks
    17
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11

    Default Setting colour on qslider

    Hi,

    I Am trying to set colour for half of slider which is vertical,but I Am not able to do.

    Can you please suggest how to do????

    Thanks in Advance......

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Setting colour on qslider

    You mean something like a red upper half and a green lower half?

  3. #3
    Join Date
    Apr 2011
    Location
    Hyderabad
    Posts
    86
    Thanks
    17
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11

    Default Re: Setting colour on qslider

    Exactly....but I want to set only lowerhalf with red colour....

  4. #4
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Setting colour on qslider

    You can fake it with the border image:
    Qt Code:
    1. #include <QApplication>
    2. #include <QSlider>
    3.  
    4. int main(int argc, char **argv)
    5. {
    6. QApplication app(argc, argv);
    7.  
    8. QSlider slider(Qt::Vertical);
    9. slider.resize(40, 300);
    10. slider.setStyleSheet(" QSlider { border-image: url('bg.png') 0 0 0 0 stretch stretch; } " );
    11. slider.show();
    12. return app.exec();
    13. }
    To copy to clipboard, switch view to plain text mode 
    with a file bg.png that is an 18x18 pixel square with a transparent upper half, and coloured lower half.
    bg.png

Similar Threads

  1. Replies: 4
    Last Post: 1st December 2011, 20:53
  2. fade from one colour to another
    By panduro in forum Newbie
    Replies: 2
    Last Post: 18th June 2008, 14:30
  3. Same shape different colour
    By anafor2004 in forum Newbie
    Replies: 5
    Last Post: 11th February 2008, 11:02
  4. Column Colour
    By sumsin in forum Qt Programming
    Replies: 8
    Last Post: 15th June 2006, 11:38
  5. background colour
    By kw in forum Qt Programming
    Replies: 6
    Last Post: 11th April 2006, 01:44

Tags for this Thread

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.