Results 1 to 3 of 3

Thread: How to paint with QLinearGradient in QLabel?

  1. #1
    Join Date
    Apr 2012
    Location
    Georgia/Rustavi
    Posts
    5
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default How to paint with QLinearGradient in QLabel?

    Hello every body...

    That's my 2 rd thread on this forum.

    I have a pretty newbie question, how to paint with QLinearGradient on QLabel?

    I have the code, but I don't know how to paint on label_3...

    Qt Code:
    1. QLinearGradient gradient(50,100,300,350);
    2. gradient.setColorAt(0.0,Qt::white);
    3. gradient.setColorAt(0.1,Qt::black);
    4. gradient.setColorAt(1.0,Qt::green);
    5. gradient.start();
    To copy to clipboard, switch view to plain text mode 
    Should I set parent, or child or something like that ? ? ?

    sorry for newbie questions.


    Thanks.
    I'm not here, not in this world. I'm in the astral part of my mind.
    I'm half dead.

  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: How to paint with QLinearGradient in QLabel?

    Assuming you are trying to produce some sort of custom widget then you should sub-class QLabel, reimplement QWidget::paintEvent() and do your painting there. See the Analogue Clock Example.

    You may be able to achieve a similar result using style sheets, particularly the background property

  3. The following user says thank you to ChrisW67 for this useful post:

    programmer251 (2nd May 2012)

  4. #3
    Join Date
    Apr 2012
    Location
    Georgia/Rustavi
    Posts
    5
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: How to paint with QLinearGradient in QLabel?

    thanks. )
    I'm not here, not in this world. I'm in the astral part of my mind.
    I'm half dead.

Similar Threads

  1. Replies: 0
    Last Post: 8th September 2011, 07:53
  2. don't work qlineargradient for text in QLabel
    By GreenScape in forum Qt Programming
    Replies: 7
    Last Post: 29th July 2010, 16:59
  3. Replies: 1
    Last Post: 29th September 2009, 19:44
  4. Regarding qlineargradient
    By jjbabu in forum Qt Programming
    Replies: 6
    Last Post: 15th April 2009, 09:21
  5. QLinearGradient question
    By ^NyAw^ in forum Qt Programming
    Replies: 3
    Last Post: 7th March 2008, 16:52

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.