1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
| #include <QtGui>
class MyTest : public QWidget
{
public:
MyTest ( QWidget * parent = 0, Qt::WindowFlags f = 0 ) : QWidget (parent,f){
afficherGraphique();
};
void afficherGraphique()
{
QPen pen;
pen.setColor (Qt::red);
pen.setWidth (4);
QGraphicsScene scene;
scene.addEllipse(-10, -10, 20, 20,pen);
scene.addLine(10,10,200,200,pen);
QGraphicsView vue(&scene);
vue.show();
}
};
int main(int argc, char* argv[])
{
QApplication app(argc, argv);
MyTest win;
win.resize(300, 300);
win.show();
return app.exec();
} |
Partager