MoaLaiSkirulais
12th February 2008, 12:39
look at this code, it only draw ONE ellipse.
I want to draw TWO ellipses.
What is wrong here?? :mad::mad:
shape.cpp
void shape::paintEvent( QPaintEvent * )
{
QPainter painter( this );
QRectF rectangle1(10.0, 20.0, 80.0, 60.0);
painter.drawEllipse(rectangle1);
QRectF rectangle2(100.0, 200.0, 80.0, 60.0);
painter.drawEllipse(rectangle2);
}
void shape::drawMyCircle()
{
QPainter painter( this );
QRectF rectangle(150.0, 250.0, 80.0, 60.0);
painter.drawEllipse(rectangle);
}
main.cpp
#include "shape.h"
#include <QApplication>
int main( int argc, char **argv )
{
QApplication a ( argc, argv );
shape myShape;
myShape.resize(640, 480);
myShape.show();
myShape.drawMyCircle ();
myShape.show(); //<--- why dont refresh?
return a.exec ();
}
I want to draw TWO ellipses.
What is wrong here?? :mad::mad:
shape.cpp
void shape::paintEvent( QPaintEvent * )
{
QPainter painter( this );
QRectF rectangle1(10.0, 20.0, 80.0, 60.0);
painter.drawEllipse(rectangle1);
QRectF rectangle2(100.0, 200.0, 80.0, 60.0);
painter.drawEllipse(rectangle2);
}
void shape::drawMyCircle()
{
QPainter painter( this );
QRectF rectangle(150.0, 250.0, 80.0, 60.0);
painter.drawEllipse(rectangle);
}
main.cpp
#include "shape.h"
#include <QApplication>
int main( int argc, char **argv )
{
QApplication a ( argc, argv );
shape myShape;
myShape.resize(640, 480);
myShape.show();
myShape.drawMyCircle ();
myShape.show(); //<--- why dont refresh?
return a.exec ();
}