5 * 1. Créer le fichier hello.pro :
6 * +------------------------------------------------------------+
8 * |CONFIG += qt debug |
9 * |SOURCES += hello.cc |
10 * +------------------------------------------------------------+
12 * 2. Créer le fichier Makefile avec la commande :
13 * $ qmake -makefile hello.pro
14 * ou tout simplement :
17 * 3. Compiler avec la commande :
24 #include <QApplication>
25 #include <DrawingWindow.h>
31 return rand() / (float )RAND_MAX;
34 void exemple1(DrawingWindow &w)
36 const int cx = w.width / 2;
37 const int cy = w.height / 2;
39 for (int x = 0; x < w.width; x += delta) {
40 w.drawLine(cx, cy, x, 0);
41 w.drawLine(cx, cy, w.width - 1 - x, w.height - 1);
43 for (int y = 0; y < w.height; y += delta) {
44 w.drawLine(cx, cy, 0, w.height - 1 - y);
45 w.drawLine(cx, cy, w.width - 1, y);
49 void exemple2(DrawingWindow &w)
51 int width = std::min(w.width, w.height) / 2;
52 for (int z = 0; z <= width; z++) {
54 float s = 3.0 * z / width;
55 if (z <= width / 3.0) {
59 } else if (z <= 2.0 * width / 3.0) {
71 w.drawRect(z, z, w.width - 1 - z, w.height - 1 - z);
75 void exemple3(DrawingWindow &w)
78 int x1 = rand() % w.width;
79 int y1 = rand() % w.height;
80 int x2 = rand() % w.width;
81 int y2 = rand() % w.height;
82 w.setColor(frand(), frand(), frand());
83 w.drawLine(x1, y1, x2, y2);
88 int main(int argc, char *argv[])
90 QApplication application(argc, argv);
91 DrawingWindow window1(exemple1, 640, 480);
92 DrawingWindow window2(exemple2, 640, 480);
93 DrawingWindow window3(exemple3, 640, 480);
95 window1.setWindowTitle("Exemple 1");
96 window2.setWindowTitle("Exemple 2");
97 window3.setWindowTitle("Exemple 3");
103 return application.exec();