summaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
authorDavid Boddie <dboddie@trolltech.com>2009-12-04 16:00:13 (GMT)
committerDavid Boddie <dboddie@trolltech.com>2009-12-04 16:00:13 (GMT)
commit0ec20e4fdd70dc11df5932ea2c282efce21dee15 (patch)
tree7387b1db111bb0930e6e01c0b405112a0b317343 /examples
parent8577da4a70be7400b1dc7d2265a31de46f8e8bb9 (diff)
parent33441e2a611f07207b0b942368aab9010cdf8ab1 (diff)
downloadQt-0ec20e4fdd70dc11df5932ea2c282efce21dee15.zip
Qt-0ec20e4fdd70dc11df5932ea2c282efce21dee15.tar.gz
Qt-0ec20e4fdd70dc11df5932ea2c282efce21dee15.tar.bz2
Merge branch '4.6' of git@scm.dev.nokia.troll.no:qt/oslo-staging-1 into 4.6
Diffstat (limited to 'examples')
-rw-r--r--examples/dialogs/standarddialogs/dialog.cpp2
-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/scribble/scribblearea.cpp5
-rw-r--r--examples/widgets/softkeys/softkeys.cpp16
-rw-r--r--examples/widgets/softkeys/softkeys.h2
-rw-r--r--examples/widgets/tablet/tabletcanvas.cpp30
-rw-r--r--examples/widgets/tablet/tabletcanvas.h8
-rw-r--r--examples/xml/saxbookmarks/mainwindow.cpp7
12 files changed, 43 insertions, 36 deletions
diff --git a/examples/dialogs/standarddialogs/dialog.cpp b/examples/dialogs/standarddialogs/dialog.cpp
index 6e06190..270fdd0 100644
--- a/examples/dialogs/standarddialogs/dialog.cpp
+++ b/examples/dialogs/standarddialogs/dialog.cpp
@@ -124,7 +124,7 @@ Dialog::Dialog(QWidget *parent)
errorLabel = new QLabel;
errorLabel->setFrameStyle(frameStyle);
QPushButton *errorButton =
- new QPushButton(tr("QErrorMessage::show&M&essage()"));
+ new QPushButton(tr("QErrorMessage::showM&essage()"));
connect(integerButton, SIGNAL(clicked()), this, SLOT(setInteger()));
connect(doubleButton, SIGNAL(clicked()), this, SLOT(setDouble()));
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/scribble/scribblearea.cpp b/examples/widgets/scribble/scribblearea.cpp
index 6c9d8aa..2bc2a69 100644
--- a/examples/widgets/scribble/scribblearea.cpp
+++ b/examples/widgets/scribble/scribblearea.cpp
@@ -139,11 +139,12 @@ void ScribbleArea::mouseReleaseEvent(QMouseEvent *event)
}
//! [12] //! [13]
-void ScribbleArea::paintEvent(QPaintEvent * /* event */)
+void ScribbleArea::paintEvent(QPaintEvent *event)
//! [13] //! [14]
{
QPainter painter(this);
- painter.drawImage(QPoint(0, 0), image);
+ QRect dirtyRect = event->rect();
+ painter.drawImage(dirtyRect, image, dirtyRect);
}
//! [14]
diff --git a/examples/widgets/softkeys/softkeys.cpp b/examples/widgets/softkeys/softkeys.cpp
index 69b4941..d1586a5 100644
--- a/examples/widgets/softkeys/softkeys.cpp
+++ b/examples/widgets/softkeys/softkeys.cpp
@@ -66,11 +66,11 @@ MainWindow::MainWindow(QWidget *parent)
infoLabel = new QLabel(tr(""), this);
infoLabel->setContextMenuPolicy(Qt::NoContextMenu);
- toggleButton = new QPushButton(tr("Custom softkeys"), this);
+ toggleButton = new QPushButton(tr("Custom"), this);
toggleButton->setContextMenuPolicy(Qt::NoContextMenu);
toggleButton->setCheckable(true);
- pushButton = new QPushButton(tr("Open File Dialog"), this);
+ pushButton = new QPushButton(tr("File Dialog"), this);
pushButton->setContextMenuPolicy(Qt::NoContextMenu);
QComboBox* comboBox = new QComboBox(this);
@@ -81,12 +81,12 @@ MainWindow::MainWindow(QWidget *parent)
<< QApplication::translate("MainWindow", "Selection3", 0, QApplication::UnicodeUTF8)
);
- layout = new QVBoxLayout;
- layout->addWidget(textEditor);
- layout->addWidget(infoLabel);
- layout->addWidget(toggleButton);
- layout->addWidget(pushButton);
- layout->addWidget(comboBox);
+ layout = new QGridLayout;
+ layout->addWidget(textEditor, 0, 0, 1, 2);
+ layout->addWidget(infoLabel, 1, 0, 1, 2);
+ layout->addWidget(toggleButton, 2, 0);
+ layout->addWidget(pushButton, 2, 1);
+ layout->addWidget(comboBox, 3, 0, 1, 2);
central->setLayout(layout);
fileMenu = menuBar()->addMenu(tr("&File"));
diff --git a/examples/widgets/softkeys/softkeys.h b/examples/widgets/softkeys/softkeys.h
index 178ae64..1372fa4 100644
--- a/examples/widgets/softkeys/softkeys.h
+++ b/examples/widgets/softkeys/softkeys.h
@@ -61,7 +61,7 @@ public:
MainWindow(QWidget *parent = 0);
~MainWindow();
private:
- QVBoxLayout *layout;
+ QGridLayout *layout;
QWidget *central;
QTextEdit* textEditor;
QLabel *infoLabel;
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;
diff --git a/examples/xml/saxbookmarks/mainwindow.cpp b/examples/xml/saxbookmarks/mainwindow.cpp
index 49cb468..ff3cf11 100644
--- a/examples/xml/saxbookmarks/mainwindow.cpp
+++ b/examples/xml/saxbookmarks/mainwindow.cpp
@@ -67,8 +67,11 @@ MainWindow::MainWindow()
void MainWindow::open()
{
#if defined(Q_OS_SYMBIAN)
- // Always look for bookmarks on the same drive where the application is installed to.
- QString bookmarksFolder = QCoreApplication::applicationFilePath().left(1);
+ // Look for bookmarks on the same drive where the application is installed to,
+ // if drive is not read only. QDesktopServices::DataLocation does this check,
+ // and returns writable drive.
+ QString bookmarksFolder =
+ QDesktopServices::storageLocation(QDesktopServices::DataLocation).left(1);
bookmarksFolder.append(":/Data/qt/saxbookmarks");
QDir::setCurrent(bookmarksFolder);
#endif