Results 1 to 4 of 4

Thread: Can I set image for qwt dial

  1. #1
    Join Date
    Feb 2008
    Posts
    36
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Default Can I set image for qwt dial

    Hi, Do you know Whether I can put image for qwt dial.Because I use qwt needle but I want to an image to dial for number screen of dial.
    Last edited by validator; 4th February 2008 at 09:03.

  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: Can I set image for qwt dial

    Overload one of the draw methods of QwtDial (drawContents, drawScaleContents ... ) and scale/draw your image there.

    Uwe

  3. #3
    Join Date
    Nov 2008
    Posts
    22
    Qt products
    Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11

    Default Re: Can I set image for qwt dial

    I wanted to paint the background of my QwtDial, but nothing happens when I follow Uwe's suggestion. Here is the code in my function:
    Qt Code:
    1. void SpeedoMeter::drawScaleContents(QPainter *painter,
    2. const QPoint &center, int radius) const
    3. {
    4. QRect rect(0, 0, 2 * radius, 2 * radius - 10);
    5.  
    6. const QColor color =
    7. #if QT_VERSION < 0x040000
    8. colorGroup().text();
    9. #else
    10. palette().color(QPalette::Text);
    11. #endif
    12. painter->setPen(color);
    13.  
    14. const int flags = Qt::AlignBottom | Qt::AlignHCenter;
    15.  
    16. rect.moveCenter(QPoint(center.x()+radius*.7,center.y()-radius));
    17. painter->drawText(rect, flags, d_label);
    18.  
    19. QRadialGradient gradient(50, 50, 50, 50, 50);
    20. gradient.setColorAt(0, QColor::fromRgbF(0, 1, 0, 1));
    21. gradient.setColorAt(1, QColor::fromRgbF(0, 0, 0, 0));
    22.  
    23. QBrush brush(gradient);
    24. painter->setBrush(gradient);
    25. painter->setBackground(brush);
    26. painter->setBackgroundMode(Qt::OpaqueMode);
    27.  
    28. }
    To copy to clipboard, switch view to plain text mode 
    Any help would be appreciated.
    // Sal

  4. #4
    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: Can I set image for qwt dial

    Quote Originally Posted by windsword View Post
    I wanted to paint the background of my QwtDial, but nothing happens ...
    Setting painter attributes only doesn't paint anything.

    Uwe

Similar Threads

  1. Finding marks on scanned image for alignment
    By caduel in forum Qt Programming
    Replies: 1
    Last Post: 23rd September 2007, 02:10
  2. Explanation to Image Formats
    By sincnarf in forum Qt Programming
    Replies: 13
    Last Post: 6th July 2007, 17:02
  3. Help needed handling image data
    By toratora in forum General Programming
    Replies: 2
    Last Post: 11th May 2007, 09:24
  4. how i can add image in my toolbar
    By jyoti in forum Qt Tools
    Replies: 7
    Last Post: 19th December 2006, 14:39
  5. How and when to repaint a widget ?
    By yellowmat in forum Newbie
    Replies: 7
    Last Post: 3rd April 2006, 16:36

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.