alex_sh
19th October 2011, 20:14
Hello,
I'm porting a QPainter-based code (written in absolute coordinates) to Qwt plot item. Normally the porting consists of transforming the coordinates using QwtScaleMap::transform() and using QwtPainter's static draw*() functions. But the original code uses QPainter::rotate() which really screws it all up and gives some really strange (and inexplicable) results.
For example,
for(int i=0; i<50; i++) {
painter->save();
painter->rotate(-90 - i*7.2);
QwtPainter::drawText(painter, QwtScaleMap::transform(xMap, yMap, QRectF(-14,-595,100,100)),
Qt::AlignLeft | Qt::AlignBottom, QString::number);
painter->restore();
}
Basically, what it does (in the original) is that it draw the numbers radially around a circle (think numbers around a dial).
I can use a separate QTransform object, rotate it and map that rectangle to it, giving me the text approximately where I want it. But, it's still off enough to be bad, and the text itself is not rotated (and I really need that).
Is there a way to make the painter rotation work with Qwt? Or maybe draw the rotated text some other way?
Thanks in advance!
Alexander
I'm porting a QPainter-based code (written in absolute coordinates) to Qwt plot item. Normally the porting consists of transforming the coordinates using QwtScaleMap::transform() and using QwtPainter's static draw*() functions. But the original code uses QPainter::rotate() which really screws it all up and gives some really strange (and inexplicable) results.
For example,
for(int i=0; i<50; i++) {
painter->save();
painter->rotate(-90 - i*7.2);
QwtPainter::drawText(painter, QwtScaleMap::transform(xMap, yMap, QRectF(-14,-595,100,100)),
Qt::AlignLeft | Qt::AlignBottom, QString::number);
painter->restore();
}
Basically, what it does (in the original) is that it draw the numbers radially around a circle (think numbers around a dial).
I can use a separate QTransform object, rotate it and map that rectangle to it, giving me the text approximately where I want it. But, it's still off enough to be bad, and the text itself is not rotated (and I really need that).
Is there a way to make the painter rotation work with Qwt? Or maybe draw the rotated text some other way?
Thanks in advance!
Alexander