Results 1 to 5 of 5

Thread: Drawing a line with a linear gradient effect

  1. #1
    Join Date
    Mar 2008
    Location
    France
    Posts
    149
    Thanks
    2
    Thanked 21 Times in 21 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Drawing a line with a linear gradient effect

    Hello,

    I need for an app to be able to draw simple lines with gradient effect.

    After doing some research , i've found in Qt Labs Blog that is possible to set the palette brush on either a painter pen (or a painter brush) using this kind of code :
    Qt Code:
    1. // Use the QPalette::Button role’s brush entry as a pen
    2. painter->setPen(QPen(palette.button(), 0));
    3. painter->drawLine(rect.topLeft(), rect.topRight());
    To copy to clipboard, switch view to plain text mode 

    What i don't get is how to set the QPalette::Button role’s brush to a gradient.

    In Qt Assistant , they say that QPalette::BrightText role can be used as well to draw lines. What are the differences ?

    Regards.

    Olivier

  2. #2
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: Drawing a line with a linear gradient effect

    Salut,

    as far as I know you don't have a possibility to get the gradient of a push button. This is because the gradient is composed direct in the styles "paint event" using the defined colours with modifications (QColor::darker() and lighter). So you have to compose your own gradient. Or have a look at the sources of a style how they draw the gradient and take that code to your drawing.

    Lykurg

  3. #3
    Join Date
    Mar 2008
    Location
    France
    Posts
    149
    Thanks
    2
    Thanked 21 Times in 21 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Drawing a line with a linear gradient effect

    Merci.

    I'll have a look at the sources.
    I wil, as well,l investigate further on this QPalette::BrightText role.
    I do believe KDE as implemented this kind of gradient line. Maybe someone has got some tech specs on that matter.
    In case of any progress in this matter, i'll get back to you to you Lukurg.

    Auf Wiedersehen.

  4. #4
    Join Date
    Mar 2008
    Location
    France
    Posts
    149
    Thanks
    2
    Thanked 21 Times in 21 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Drawing a line with a linear gradient effect

    Lykurg , I mean.

  5. #5
    Join Date
    Mar 2008
    Location
    France
    Posts
    149
    Thanks
    2
    Thanked 21 Times in 21 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Drawing a line with a linear gradient effect


Similar Threads

  1. QprogressBar Style Sheets: double linear gradient
    By Beppe in forum Qt Programming
    Replies: 6
    Last Post: 8th May 2009, 14:41
  2. drawing an unfixed line?
    By tommy in forum Newbie
    Replies: 7
    Last Post: 26th January 2008, 17:18
  3. Line drawing in Designer
    By Doug Broadwell in forum Newbie
    Replies: 8
    Last Post: 28th March 2007, 00:02
  4. Line drawing
    By kiranraj in forum Qt Programming
    Replies: 1
    Last Post: 29th January 2007, 06:38
  5. drawing shadow effect
    By vijay anandh in forum Qt Programming
    Replies: 1
    Last Post: 25th May 2006, 15:41

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.