Unsolved QPainter, QPixmap, drawPie and Transformations
-
I have a PNG image which I've loaded into my application as a
QPixmap
.What I'm looking to do is to stretch this image into the shape of a pie slice and draw it using the
QPainter::drawPie
function.Having loaded a new
QBrush
instance with theQPixmap
, I now need to somehow transform the brush to the shape of the pie.Any clues as to how this may be achieved? Thank you in advance for any hints
-
hi
Hmm
DrawPie will use any brush set to fill the pie.
I assume you want it filled other than how brush does ? -
@mrjj You are indeed correct - I want the brush to be
transformed
so that theQPixmap
is adjusted to fill the interior of the pie, assuming the shape of the pie. -
@webzoid
It does have
void QBrush::setTransform(const QTransform & matrix)
but its unclear how you mean it should be draw since
it does brush does fill the interior but will do so in a reaping manner. -
@mrjj Sorry, I'm not explaining this very well...
Imagine the point of the pie slice. The bitmap should be drawn such that the pixels on the bottom row are squashed into this point. Then imagine the curve of the pie slice, the top row of the bitmap (and nearby pixels) would be stretched and transformed to fit in the curve.
All other pixels within the bitmap would also be transformed to fill the remaining area of the pie slice.
Does that make any sense at all :)
-
@webzoid
Hmm i think i get it now, like a perfect fit for the pixmap
and not just filled as repeating fill.
Something like
https://stackoverflow.com/questions/30980484/qt-fill-circle-with-images
?