Its ok to ask again and again if you follow up carefully.
ya i know that draw can be done only in paintevent function
Can u then explain the code -
void circleForm::repaint(){
painter.drawEllipse(100,20,180,180);
}
// void paintEvent(QPaintEvent *event);
void circleForm::repaint(){
QPainter painter(this);
painter.drawEllipse(100,20,180,180);
}
// void paintEvent(QPaintEvent *event);
To copy to clipboard, switch view to plain text mode
. Connect them to the update slot of your widget. By calling update() a paint event is automatically emitted. Then, inside your paintEvent method, get your parameters and paint your circle.
Thats what lykurg said.
So your paintevent shud be something like -
myWidget::paintEvent()
{
if(needToDrawCircle)
// draw circle.
}
//and in ur slot -
myWidget::slotEneterPressed()
{
needToDrawCircle = true;
}
myWidget::paintEvent()
{
if(needToDrawCircle)
// draw circle.
}
//and in ur slot -
myWidget::slotEneterPressed()
{
needToDrawCircle = true;
}
To copy to clipboard, switch view to plain text mode
and you will need more member variables to store the radius and position of circle if necessary.
Bookmarks