Results 1 to 3 of 3

Thread: QLinearGradient and QwtThermo

  1. #1
    Join Date
    May 2009
    Posts
    20
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default QLinearGradient and QwtThermo

    hello,

    I'm wondering how I should setup a QLinearGradient to fill the liquid in a QwtThermo widget.
    For example:

    Qt Code:
    1. QwtThermo *myThermo;
    2.  
    3. myThermo = new QwtThermo();
    4. QLinearGradient g(a, b, c, d) // <----- see text below;
    5. g.setColorAt(0, Qt::red);
    6. g.setColorAt(0, Qt::yellow);
    7. myThermo->setFillBrush(QBrush(g));
    To copy to clipboard, switch view to plain text mode 

    what values I should write instead of a, b, c, d to cover the whole liquid rectangle?

    Thanks!
    Marco

  2. #2
    Join Date
    Feb 2006
    Location
    Munich, Germany
    Posts
    3,309
    Thanked 879 Times in 827 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QLinearGradient and QwtThermo

    Quote Originally Posted by Marco Trapanese View Post
    I'm wondering how I should setup a QLinearGradient to fill the liquid in a QwtThermo widget.
    I'm afraid, that there is no solution without patching Qwt.

    a) The rectangle for the liquid is calculated in layoutThermo what needs to become virtual so, that you could overload it.
    b) You need to introduce a method, that calculates the fill rectangle ( like it is done in drawThermo() ).

    Then you could adjust your brush at the end of YourThermo::layoutThermo after calling layoutThermo of the base class according to the fill rectangle.

    Uwe

    PS: Unfortunately almost all development in the last years was for the plot framework only and the other widgets were never updated to many new features of Qt4. Hope I will find some the time when Qt 6 is out.

  3. #3
    Join Date
    May 2009
    Posts
    20
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: QLinearGradient and QwtThermo

    I don't know if it's the right way but I've just found a solution:

    Qt Code:
    1. QLinearGradient gradient;
    2. gradient.setCoordinateMode(QGradient::ObjectBoundingMode);
    3. gradient.setStart(0, 0);
    4. gradient.setFinalStop(1, 1);
    To copy to clipboard, switch view to plain text mode 

    the rectangle (0, 0) (1, 1) now cover the whole liquid surface if I'm not wrong. Actually, I'm using an horizontal linear gradient so it starts from (0, 0) and goes up to (0.75, 0).

    Marco


    ps. I'm customizing a lot of instrumentation gauges because most of them are incomplete or miss some common features.
    Do you know if there is a *complete* suite of gauges for QT (no problem if payware)? Something like Dundas Gauge for .NET or similar?

Similar Threads

  1. QwtThermo: origin of the fill
    By Marco Trapanese in forum Qwt
    Replies: 0
    Last Post: 31st May 2010, 15:50
  2. QwtThermo ScalePos
    By jhowland in forum Qwt
    Replies: 1
    Last Post: 30th December 2009, 02:53
  3. Regarding qlineargradient
    By jjbabu in forum Qt Programming
    Replies: 6
    Last Post: 15th April 2009, 10:21
  4. Related QLinearGradient
    By ashishsaryar in forum Qt Programming
    Replies: 5
    Last Post: 26th May 2008, 11:09
  5. QLinearGradient question
    By ^NyAw^ in forum Qt Programming
    Replies: 3
    Last Post: 7th March 2008, 17: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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.