Difficulty central pixmap inside Ellipse
drawPixmap-Drawing rectangular portion source of the given image into target rectangle
Having difficulty central pixmap inside Ellipse
QTimer *timer = new QTimer(this);
connect(timer, SIGNAL(timeout()), this, SLOT(update()));
setWindowTitle(tr("MyWidget")); resize(200, 200);
void CirclePict::paintEvent(QPaintEvent *)
QPixmap pm(100,100); pm.fill(); painter.setRenderHint(QPainter::Antialiasing); QPen pen1(Qt::red,6); painter.setPen(pen1); QRectF rectangle(20.0,20.0,160.0,180.0); QRectF CircleRect(10,10,180,180); QRectF source(0.0,0.0,70.0,70.0); QPixmap pixmap(":house.png"); painter.drawPixmap(rectangle,pixmap,source); painter.drawEllipse(CircleRect);
Can you explain what you are trying to achieve and what is currently happening ?
Want to centre a pixmap in a circle.
The pixmap is not central entirely inside the circle. A bit of the pixmap is outside this circle.
The class is circlepict.cpp in github
You need to do some maths to either calculate the size of a rectangle for a given circle or the circle for a given rectangle.