PDA

View Full Version : Problem with resizing circle



SeNSe
9th April 2010, 10:22
I drew a circle using addEclipse command in the paintevent and the boundary using the Qpainterpath. I wanted to resize the circle and move the circle . So I created a button for resizing . Whn I click on tht button , i change the radius in the mousemoveevent .Its all working fine . The PROBELM tht I m getting is tht whn I m increasing the radius the boundary is not increasing smoothly , i meant to say tht while transitioning boundary is getting thinner . After I release the button the boundary is fine . Also whn I m moving the circle , the boundary disappears sometime.
Can somebody suggest me wht to do .....

Lykurg
9th April 2010, 10:28
Can somebody suggest me wht to do .....
How could we without seeing any pice of your code!

SeNSe
9th April 2010, 10:44
void class :: mouseMoveEvent(QMouseEvent *event)
{
m_position_old = event->globalPos();
}


void class :: paintEvent(QPaintEvent *event)
{
Painter painter;
painter.begin(this);
QPen myPen;
myPen.setWidth(10);
myPen.setColor(QColor(128,128,128));
painter.setPen(myPen);
int PixPosX = m_position_old.x();
int PixPosY = m_position_old.y();
QRegion maskregion;
QPainterPath magPainterPath;
QRect rectMagWnd(PixPosX-Radius,PixPosY-Radius,2*Radius,2*Radius);

magPainterPath.addEllipse(rectMagWnd);
resizeBtn->setGeometry(rectMagWnd.x()+rectMagWnd.width()-pixWidth,rectMagWnd.y()+rectMagWnd.height()/2-pixHeight,pixWidth,pixHeight);
closeBtn->setGeometry(resizeBtn->x()-2,resizeBtn->y()+25,pixWidth,pixHeight);
shapeBtn->setGeometry(resizeBtn->x()-7,resizeBtn->y()+50,pixWidth,pixHeight);
zoomBtn->setGeometry(resizeBtn->x()-15,resizeBtn->y()+75,pixWidth,pixHeight);

painter.setClipPath(magPainterPath);
maskregion=painter.clipRegion();
setMask(maskregion);
painter.drawPath(magPainterPath);
painter.end();

}


I m changing radius in the mousemoveevent ... It is not relevant so I hvn't shown it
Now I guess you must know wht I was saying earlier