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 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60
| #include <QApplication>
#include <QTimer>
#include <QObject>
#include <QPixmap>
#include <QLabel>
#include <QList>
#include <QPainter>
int rectangle(QPixmap * image,int Ycoord)
{ QPainter pinceau(image) ;
pinceau.drawRect(50,Ycoord,460,40) ;
return 0 ;
}
QPixmap vertimage(int longueur,int largeur)
{ QPixmap image(longueur,largeur) ;
image.fill(Qt::green) ;
return image ;
}
int main(int argc,char * argv[])
{ QApplication app(argc,argv) ;
QPixmap image(vertimage(600,510)) ;
QList <QPixmap> uneliste ;
rectangle(&image,10 ) ;
uneliste.operator<<(image) ;
rectangle(&image,60 ) ;
uneliste.operator<<(image) ;
rectangle(&image,110 ) ;
uneliste.operator<<(image) ;
rectangle(&image,160 ) ;
uneliste.operator<<(image) ;
rectangle(&image,210 ) ;
uneliste.operator<<(image) ;
rectangle(&image,260 ) ;
uneliste.operator<<(image) ;
rectangle(&image,310 ) ;
uneliste.operator<<(image) ;
rectangle(&image,360 ) ;
uneliste.operator<<(image) ;
rectangle(&image,410 ) ;
uneliste.operator<<(image) ;
rectangle(&image,460 ) ;
uneliste.operator<<(image) ;
QLabel monlabel ;
monlabel.setPixmap(uneliste.at(0)) ;
monlabel.show() ;
QTimer::singleShot(1000,&app,SLOT(quit()) ) ;
app.exec() ;
int ctr = 0 ;
for (ctr = 1 ; ctr < 10 ; ctr++)
{ monlabel.setPixmap(uneliste.at(ctr)) ;
monlabel.show() ;
QTimer::singleShot(1000,&app,SLOT(quit()) );
app.exec() ;
}
monlabel.show() ;
app.exec() ;
return 0 ;
} |
Partager