examples/widgets/tablet/tabletcanvas.cpp
changeset 3 41300fa6a67c
parent 0 1918ee327afb
child 4 3b1da2848fc7
--- a/examples/widgets/tablet/tabletcanvas.cpp	Tue Jan 26 12:42:25 2010 +0200
+++ b/examples/widgets/tablet/tabletcanvas.cpp	Tue Feb 02 00:43:10 2010 +0200
@@ -50,7 +50,7 @@
     resize(500, 500);
     myBrush = QBrush();
     myPen = QPen();
-    initImage();
+    initPixmap();
     setAutoFillBackground(true);
     deviceDown = false;
     myColor = Qt::red;
@@ -60,29 +60,29 @@
     lineWidthType = LineWidthPressure;
 }
 
-void TabletCanvas::initImage()
+void TabletCanvas::initPixmap()
 {
-    QImage newImage = QImage(width(), height(), QImage::Format_ARGB32);
-    QPainter painter(&newImage);
-    painter.fillRect(0, 0, newImage.width(), newImage.height(), Qt::white);
-    if (!image.isNull())
-        painter.drawImage(0, 0, image);
+    QPixmap newPixmap = QPixmap(width(), height());
+    newPixmap.fill(Qt::white);
+    QPainter painter(&newPixmap);
+    if (!pixmap.isNull())
+        painter.drawPixmap(0, 0, pixmap);
     painter.end();
-    image = newImage;
+    pixmap = newPixmap;
 }
 //! [0]
 
 //! [1]
 bool TabletCanvas::saveImage(const QString &file)
 {
-    return image.save(file);
+    return pixmap.save(file);
 }
 //! [1]
 
 //! [2]
 bool TabletCanvas::loadImage(const QString &file)
 {
-    bool success = image.load(file);
+    bool success = pixmap.load(file);
 
     if (success) {
         update();
@@ -114,8 +114,8 @@
 
             if (deviceDown) {
                 updateBrush(event);
-                QPainter painter(&image);
-                paintImage(painter, event);
+                QPainter painter(&pixmap);
+                paintPixmap(painter, event);
             }
             break;
         default:
@@ -129,12 +129,12 @@
 void TabletCanvas::paintEvent(QPaintEvent *)
 {
     QPainter painter(this);
-    painter.drawImage(QPoint(0, 0), image);
+    painter.drawPixmap(0, 0, pixmap);
 }
 //! [4]
 
 //! [5]
-void TabletCanvas::paintImage(QPainter &painter, QTabletEvent *event)
+void TabletCanvas::paintPixmap(QPainter &painter, QTabletEvent *event)
 {
     QPoint brushAdjust(10, 10);
 
@@ -271,6 +271,6 @@
 
 void TabletCanvas::resizeEvent(QResizeEvent *)
 {
-    initImage();
+    initPixmap();
     polyLine[0] = polyLine[1] = polyLine[2] = QPoint();
 }