I am new to QT and I want to draw some image inside a shape and image should be croped by a shape. I use the following code to draw a rectangle for example. How to draw image only inside shape?
QPen pen(Qt::black,penWidth);
pen.setStyle(Qt::DashLine);
QPicture picture;
picture.load("drawing.pic");
painter->setPen(pen);
painter->drawPicture(0,0, picture);
painter->drawRoundedRect( (QRectF(x, y, height, width),radius,radius);
PS. Can I load an image to brush?
Just set a QBrush for painter.
QBrush brush(QPixmap("file.png"));
painter->setBrush(brush);
It will draw the rounded rect filled with file.png image.
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments