Results 1 to 4 of 4

Thread: QwtDial - multiple Background color

  1. #1
    Join Date
    Oct 2013
    Location
    Quebec
    Posts
    31
    Thanks
    4
    Qt products
    Qt5
    Platforms
    Windows

    Default QwtDial - multiple Background color

    Hi guys,

    Here is my current QwtDial
    Here is what I would like (forgive my painting skills)

    I can put one color that fit the circle totally but I'm failing at using multiple color at the same time.

    Qt Code:
    1. QPalette palette;
    2. palette.setColor( QPalette::WindowText, QColor(89, 130, 67) ); //GREEN 90-270
    3. palette.setColor( QPalette::WindowText, QColor(35, 53, 216) ); //BLUE 0-90
    4. palette.setColor( QPalette::WindowText, QColor(168, 18, 18) ); //RED 270-360
    To copy to clipboard, switch view to plain text mode 


    I'm using the DialBox example modified for my need found in the qwt/examples
    Thanks if you can give a hand to a Qwt newbie!

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

    Default Re: QwtDial - multiple Background color

    You have to overload drawScaleContents using QPainter::drawPie().

    Uwe

  3. #3
    Join Date
    Oct 2013
    Location
    Quebec
    Posts
    31
    Thanks
    4
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: QwtDial - multiple Background color

    Thanks for your answer, I will try that and post the resulting code when it's working

    [Edit]

    Got it to work, QPainter is really powerfull ! (see code below)


    Qt Code:
    1. //////////////////////////////////////////////////////////////////////////////////////////////////
    2. /*!
    3.   Draw the contents inside the scale
    4.   Paints nothing.
    5.  
    6.   \param painter Painter
    7.   \param center Center of the contents circle
    8.   \param radius Radius of the contents circle
    9. *///////////////////////////////////////////////////////////////////////////////////////////////////
    10. void myQwtDial::drawScaleContents( QPainter *painter, const QPointF &center, double radius ) const {
    11.  
    12.  
    13.  
    14. qDebug() << "X: " << center.x() << "Y : " << center.y();
    15. qDebug() << "RADIUS" << radius;
    16.  
    17.  
    18. QRectF rectangle(center.x()-radius, center.y()-radius, radius*2, radius*2);
    19.  
    20.  
    21. painter->setBrush(QBrush(Qt::darkGreen));
    22. painter->drawPie(rectangle, (0 * 16), (180 * 16) );
    23.  
    24. painter->setBrush(QBrush(Qt::blue));
    25. painter->drawPie(rectangle, (180 * 16), (90 * 16) );
    26.  
    27. painter->setBrush(QBrush(Qt::red));
    28. painter->drawPie(rectangle, (270 * 16), (90 * 16) );
    29.  
    30. }
    To copy to clipboard, switch view to plain text mode 
    Last edited by Maximus2; 26th November 2013 at 19:13.

  4. #4
    Join Date
    Oct 2013
    Location
    Quebec
    Posts
    31
    Thanks
    4
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: QwtDial - multiple Background color

    Last questions,

    1- Would it be possible to cut the QwtDial in half like this?

    2- Would it be possible to hide the black line in the circle, see example here, I guess QPainter add it automatically when using drawPie()?
    [ANSWER : Use "painter->setPen( Qt::NoPen )" on your painter, simple!]

    Thank you!
    Last edited by Maximus2; 26th November 2013 at 21:35.

Similar Threads

  1. QTreeWidgetItem and background color
    By swiety in forum Qt Programming
    Replies: 9
    Last Post: 26th October 2016, 07:25
  2. Background color
    By FelixB in forum Qwt
    Replies: 4
    Last Post: 24th June 2013, 07:03
  3. Replies: 3
    Last Post: 16th July 2012, 15:04
  4. background color for qgraphicstextitem
    By sanku in forum Qt Programming
    Replies: 0
    Last Post: 15th September 2010, 11:57
  5. QPushbutton background color
    By omega36 in forum Qt Programming
    Replies: 27
    Last Post: 31st October 2008, 12:47

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.