PDA

View Full Version : Can I set image for qwt dial



validator
4th February 2008, 09:50
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.

Uwe
9th February 2008, 13:49
Overload one of the draw methods of QwtDial (drawContents, drawScaleContents ... ) and scale/draw your image there.

Uwe

windsword
16th December 2010, 14:04
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:

void SpeedoMeter::drawScaleContents(QPainter *painter,
const QPoint &center, int radius) const
{
QRect rect(0, 0, 2 * radius, 2 * radius - 10);

const QColor color =
#if QT_VERSION < 0x040000
colorGroup().text();
#else
palette().color(QPalette::Text);
#endif
painter->setPen(color);

const int flags = Qt::AlignBottom | Qt::AlignHCenter;

rect.moveCenter(QPoint(center.x()+radius*.7,center .y()-radius));
painter->drawText(rect, flags, d_label);

QRadialGradient gradient(50, 50, 50, 50, 50);
gradient.setColorAt(0, QColor::fromRgbF(0, 1, 0, 1));
gradient.setColorAt(1, QColor::fromRgbF(0, 0, 0, 0));

QBrush brush(gradient);
painter->setBrush(gradient);
painter->setBackground(brush);
painter->setBackgroundMode(Qt::OpaqueMode);

}
Any help would be appreciated.
// Sal

Uwe
17th December 2010, 07:20
I wanted to paint the background of my QwtDial, but nothing happens ...

Setting painter attributes only doesn't paint anything.

Uwe