summaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
authorOlivier Goffart <ogoffart@trolltech.com>2009-12-04 18:36:19 (GMT)
committerOlivier Goffart <ogoffart@trolltech.com>2009-12-04 18:36:19 (GMT)
commitf0bb9bc5b0f4c20536d6c77624bd148389b78c06 (patch)
tree9088a173de4bfbeea29bc9464d4cb46257df67cd /examples
parent60be72310c0f9469b3201b250b257473184ccf2a (diff)
parent1bb5999cdca0a70df3f96d596c83c3cf7c97c5fd (diff)
downloadQt-f0bb9bc5b0f4c20536d6c77624bd148389b78c06.zip
Qt-f0bb9bc5b0f4c20536d6c77624bd148389b78c06.tar.gz
Qt-f0bb9bc5b0f4c20536d6c77624bd148389b78c06.tar.bz2
Merge commit 'origin/4.6' into 4.6
Diffstat (limited to 'examples')
-rw-r--r--examples/script/helloscript/helloscript.js (renamed from examples/script/helloscript/helloscript.qs)0
-rw-r--r--examples/script/helloscript/helloscript.qrc2
-rw-r--r--examples/script/helloscript/main.cpp2
-rw-r--r--examples/script/qsdbg/example.js (renamed from examples/script/qsdbg/example.qs)0
-rw-r--r--examples/script/qsdbg/main.cpp5
-rw-r--r--examples/widgets/tablet/tabletcanvas.cpp30
-rw-r--r--examples/widgets/tablet/tabletcanvas.h8
7 files changed, 25 insertions, 22 deletions
diff --git a/examples/script/helloscript/helloscript.qs b/examples/script/helloscript/helloscript.js
index 6d8e87c..6d8e87c 100644
--- a/examples/script/helloscript/helloscript.qs
+++ b/examples/script/helloscript/helloscript.js
diff --git a/examples/script/helloscript/helloscript.qrc b/examples/script/helloscript/helloscript.qrc
index dc93461..c52fa15 100644
--- a/examples/script/helloscript/helloscript.qrc
+++ b/examples/script/helloscript/helloscript.qrc
@@ -1,5 +1,5 @@
<RCC>
<qresource prefix="/" >
- <file>helloscript.qs</file>
+ <file>helloscript.js</file>
</qresource>
</RCC>
diff --git a/examples/script/helloscript/main.cpp b/examples/script/helloscript/main.cpp
index bc9a65e..55d63bf 100644
--- a/examples/script/helloscript/main.cpp
+++ b/examples/script/helloscript/main.cpp
@@ -68,7 +68,7 @@ int main(int argc, char *argv[])
//! [2]
//! [3]
- QString fileName(":/helloscript.qs");
+ QString fileName(":/helloscript.js");
QFile scriptFile(fileName);
scriptFile.open(QIODevice::ReadOnly);
QTextStream stream(&scriptFile);
diff --git a/examples/script/qsdbg/example.qs b/examples/script/qsdbg/example.js
index 47c1363..47c1363 100644
--- a/examples/script/qsdbg/example.qs
+++ b/examples/script/qsdbg/example.js
diff --git a/examples/script/qsdbg/main.cpp b/examples/script/qsdbg/main.cpp
index 526de0c..2a86c3d 100644
--- a/examples/script/qsdbg/main.cpp
+++ b/examples/script/qsdbg/main.cpp
@@ -39,14 +39,17 @@
**
****************************************************************************/
+#include <QtCore/QCoreApplication>
#include <QtScript>
#include "scriptdebugger.h"
int main(int argc, char **argv)
{
+ QCoreApplication app(argc, argv);
+
if (argc < 2) {
- fprintf(stderr, "*** you must specify a script file to evaluate (try example.qs)\n");
+ fprintf(stderr, "*** you must specify a script file to evaluate (try example.js)\n");
return(-1);
}
diff --git a/examples/widgets/tablet/tabletcanvas.cpp b/examples/widgets/tablet/tabletcanvas.cpp
index 130498b..20b0d1e 100644
--- a/examples/widgets/tablet/tabletcanvas.cpp
+++ b/examples/widgets/tablet/tabletcanvas.cpp
@@ -50,7 +50,7 @@ TabletCanvas::TabletCanvas()
resize(500, 500);
myBrush = QBrush();
myPen = QPen();
- initImage();
+ initPixmap();
setAutoFillBackground(true);
deviceDown = false;
myColor = Qt::red;
@@ -60,29 +60,29 @@ TabletCanvas::TabletCanvas()
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 @@ void TabletCanvas::tabletEvent(QTabletEvent *event)
if (deviceDown) {
updateBrush(event);
- QPainter painter(&image);
- paintImage(painter, event);
+ QPainter painter(&pixmap);
+ paintPixmap(painter, event);
}
break;
default:
@@ -129,12 +129,12 @@ void TabletCanvas::tabletEvent(QTabletEvent *event)
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::updateBrush(QTabletEvent *event)
void TabletCanvas::resizeEvent(QResizeEvent *)
{
- initImage();
+ initPixmap();
polyLine[0] = polyLine[1] = polyLine[2] = QPoint();
}
diff --git a/examples/widgets/tablet/tabletcanvas.h b/examples/widgets/tablet/tabletcanvas.h
index 02b8794..5a2fb1d 100644
--- a/examples/widgets/tablet/tabletcanvas.h
+++ b/examples/widgets/tablet/tabletcanvas.h
@@ -43,7 +43,7 @@
#define TABLETCANVAS_H
#include <QWidget>
-#include <QImage>
+#include <QPixmap>
#include <QPoint>
#include <QTabletEvent>
#include <QColor>
@@ -92,8 +92,8 @@ protected:
void resizeEvent(QResizeEvent *event);
private:
- void initImage();
- void paintImage(QPainter &painter, QTabletEvent *event);
+ void initPixmap();
+ void paintPixmap(QPainter &painter, QTabletEvent *event);
Qt::BrushStyle brushPattern(qreal value);
void updateBrush(QTabletEvent *event);
@@ -104,7 +104,7 @@ private:
QTabletEvent::TabletDevice myTabletDevice;
QColor myColor;
- QImage image;
+ QPixmap pixmap;
QBrush myBrush;
QPen myPen;
bool deviceDown;