summaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
authorThierry Bastian <thierry.bastian@nokia.com>2009-05-22 09:28:05 (GMT)
committerThierry Bastian <thierry.bastian@nokia.com>2009-05-22 09:28:05 (GMT)
commitd0ac49ec731f0781ba48f8f5d8ce04e19ce0010d (patch)
treeba6df139b3c343bb9352423770a99f218f62bd45 /examples
parent72798fc4dfc1af73cde542f9017dfec5cb020173 (diff)
parent8ad5020940f10d4ecc5c5e8b3b9656531cb84ef3 (diff)
downloadQt-d0ac49ec731f0781ba48f8f5d8ce04e19ce0010d.zip
Qt-d0ac49ec731f0781ba48f8f5d8ce04e19ce0010d.tar.gz
Qt-d0ac49ec731f0781ba48f8f5d8ce04e19ce0010d.tar.bz2
Merge branch 'master' of git@scm.dev.nokia.troll.no:qt/qt into kinetic-animations
Conflicts: src/corelib/kernel/kernel.pri src/corelib/kernel/qvariant_p.h src/corelib/tools/tools.pri src/gui/graphicsview/qgraphicsitem.cpp src/gui/graphicsview/qgraphicsitem.h src/gui/graphicsview/qgraphicswidget.h src/gui/gui.pro
Diffstat (limited to 'examples')
-rw-r--r--examples/assistant/simpletextviewer/mainwindow.cpp6
-rw-r--r--examples/designer/taskmenuextension/tictactoeplugin.cpp8
-rw-r--r--examples/draganddrop/dropsite/dropsitewindow.cpp6
-rw-r--r--examples/draganddrop/puzzle/mainwindow.cpp4
-rw-r--r--examples/graphicsview/basicgraphicslayouts/layoutitem.cpp50
-rw-r--r--examples/graphicsview/basicgraphicslayouts/layoutitem.h12
-rw-r--r--examples/graphicsview/diagramscene/mainwindow.cpp2
-rw-r--r--examples/graphicsview/flowlayout/flowlayout.cpp210
-rw-r--r--examples/graphicsview/flowlayout/flowlayout.h77
-rw-r--r--examples/graphicsview/flowlayout/flowlayout.pro12
-rw-r--r--examples/graphicsview/flowlayout/main.cpp55
-rw-r--r--examples/graphicsview/flowlayout/window.cpp63
-rw-r--r--examples/graphicsview/flowlayout/window.h48
-rw-r--r--examples/graphicsview/padnavigator/roundrectitem.cpp13
-rw-r--r--examples/help/simpletextviewer/mainwindow.cpp6
-rw-r--r--examples/itemviews/chart/mainwindow.cpp6
-rw-r--r--examples/itemviews/pixelator/mainwindow.cpp6
-rw-r--r--examples/itemviews/puzzle/mainwindow.cpp4
-rw-r--r--examples/itemviews/simpledommodel/mainwindow.cpp4
-rw-r--r--examples/linguist/arrowpad/mainwindow.cpp2
-rw-r--r--examples/mainwindows/application/mainwindow.cpp2
-rw-r--r--examples/mainwindows/dockwidgets/mainwindow.cpp2
-rw-r--r--examples/mainwindows/mdi/mainwindow.cpp2
-rw-r--r--examples/mainwindows/menus/mainwindow.cpp8
-rw-r--r--examples/mainwindows/recentfiles/mainwindow.cpp2
-rw-r--r--examples/mainwindows/sdi/mainwindow.cpp2
-rw-r--r--examples/opengl/grabber/mainwindow.cpp2
-rw-r--r--examples/painting/svgviewer/mainwindow.cpp2
-rw-r--r--examples/phonon/musicplayer/mainwindow.cpp2
-rw-r--r--examples/richtext/orderform/mainwindow.cpp6
-rw-r--r--examples/richtext/syntaxhighlighter/mainwindow.cpp11
-rw-r--r--examples/sql/masterdetail/mainwindow.cpp2
-rw-r--r--examples/tools/codecs/mainwindow.cpp4
-rw-r--r--examples/tools/contiguouscache/contiguouscache.pro9
-rw-r--r--examples/tools/contiguouscache/main.cpp56
-rw-r--r--examples/tools/contiguouscache/randomlistmodel.cpp97
-rw-r--r--examples/tools/contiguouscache/randomlistmodel.h66
-rw-r--r--examples/tools/plugandpaint/mainwindow.cpp6
-rw-r--r--examples/tools/settingseditor/mainwindow.cpp4
-rw-r--r--examples/tools/tools.pro1
-rw-r--r--examples/tools/undoframework/mainwindow.cpp8
-rw-r--r--examples/tutorials/addressbook-fr/part1/main.cpp4
-rw-r--r--examples/tutorials/addressbook-fr/part2/main.cpp4
-rw-r--r--examples/tutorials/addressbook-fr/part3/main.cpp4
-rw-r--r--examples/tutorials/addressbook-fr/part4/main.cpp4
-rw-r--r--examples/tutorials/addressbook-fr/part5/main.cpp4
-rw-r--r--examples/tutorials/addressbook-fr/part6/main.cpp4
-rw-r--r--examples/tutorials/addressbook-fr/part7/main.cpp4
-rw-r--r--examples/tutorials/addressbook/part1/main.cpp4
-rw-r--r--examples/tutorials/addressbook/part2/main.cpp4
-rw-r--r--examples/tutorials/addressbook/part3/main.cpp4
-rw-r--r--examples/tutorials/addressbook/part4/main.cpp4
-rw-r--r--examples/tutorials/addressbook/part5/main.cpp4
-rw-r--r--examples/tutorials/addressbook/part6/main.cpp4
-rw-r--r--examples/tutorials/addressbook/part7/main.cpp4
-rw-r--r--examples/tutorials/widgets/childwidget/childwidget.pro7
-rw-r--r--examples/tutorials/widgets/childwidget/main.cpp61
-rw-r--r--examples/tutorials/widgets/nestedlayouts/main.cpp104
-rw-r--r--examples/tutorials/widgets/nestedlayouts/nestedlayouts.pro7
-rw-r--r--examples/tutorials/widgets/toplevel/main.cpp57
-rw-r--r--examples/tutorials/widgets/toplevel/toplevel.pro7
-rw-r--r--examples/tutorials/widgets/widgets.pro8
-rw-r--r--examples/tutorials/widgets/windowlayout/main.cpp63
-rw-r--r--examples/tutorials/widgets/windowlayout/windowlayout.pro7
-rw-r--r--examples/webkit/fancybrowser/mainwindow.cpp20
-rw-r--r--examples/webkit/fancybrowser/mainwindow.h4
-rw-r--r--examples/webkit/formextractor/mainwindow.cpp2
-rw-r--r--examples/webkit/previewer/mainwindow.cpp6
-rw-r--r--examples/widgets/codeeditor/codeeditor.cpp2
-rw-r--r--examples/widgets/icons/mainwindow.cpp2
-rw-r--r--examples/widgets/scribble/mainwindow.cpp4
-rw-r--r--examples/widgets/tablet/mainwindow.cpp6
-rw-r--r--examples/xml/dombookmarks/mainwindow.cpp6
-rw-r--r--examples/xml/saxbookmarks/mainwindow.cpp6
-rw-r--r--examples/xml/streambookmarks/mainwindow.cpp6
-rw-r--r--examples/xmlpatterns/trafficinfo/main.cpp2
-rw-r--r--examples/xmlpatterns/trafficinfo/mainwindow.cpp4
-rw-r--r--examples/xmlpatterns/trafficinfo/mainwindow.h2
-rw-r--r--examples/xmlpatterns/trafficinfo/stationdialog.cpp2
-rw-r--r--examples/xmlpatterns/trafficinfo/stationdialog.h2
-rw-r--r--examples/xmlpatterns/trafficinfo/stationquery.cpp2
-rw-r--r--examples/xmlpatterns/trafficinfo/stationquery.h2
-rw-r--r--examples/xmlpatterns/trafficinfo/timequery.cpp2
-rw-r--r--examples/xmlpatterns/trafficinfo/timequery.h2
84 files changed, 1210 insertions, 139 deletions
diff --git a/examples/assistant/simpletextviewer/mainwindow.cpp b/examples/assistant/simpletextviewer/mainwindow.cpp
index cc2f3c0..f7c7098 100644
--- a/examples/assistant/simpletextviewer/mainwindow.cpp
+++ b/examples/assistant/simpletextviewer/mainwindow.cpp
@@ -101,11 +101,11 @@ void MainWindow::open()
void MainWindow::createActions()
{
assistantAct = new QAction(tr("Help Contents"), this);
- assistantAct->setShortcut(tr("F1"));
+ assistantAct->setShortcuts(QKeySequence::HelpContents);
connect(assistantAct, SIGNAL(triggered()), this, SLOT(assistant()));
openAct = new QAction(tr("&Open..."), this);
- openAct->setShortcut(tr("Ctrl+O"));
+ openAct->setShortcuts(QKeySequence::Open);
connect(openAct, SIGNAL(triggered()), this, SLOT(open()));
clearAct = new QAction(tr("&Clear"), this);
@@ -113,7 +113,7 @@ void MainWindow::createActions()
connect(clearAct, SIGNAL(triggered()), textViewer, SLOT(clear()));
exitAct = new QAction(tr("E&xit"), this);
- exitAct->setShortcut(tr("Ctrl+Q"));
+ exitAct->setShortcuts(QKeySequence::Quit);
connect(exitAct, SIGNAL(triggered()), this, SLOT(close()));
aboutAct = new QAction(tr("&About"), this);
diff --git a/examples/designer/taskmenuextension/tictactoeplugin.cpp b/examples/designer/taskmenuextension/tictactoeplugin.cpp
index 1333090..0a2d13b 100644
--- a/examples/designer/taskmenuextension/tictactoeplugin.cpp
+++ b/examples/designer/taskmenuextension/tictactoeplugin.cpp
@@ -124,6 +124,14 @@ QString TicTacToePlugin::domXml() const
return QLatin1String("\
<ui language=\"c++\">\
<widget class=\"TicTacToe\" name=\"ticTacToe\"/>\
+ <customwidgets>\
+ <customwidget>\
+ <class>TicTacToe</class>\
+ <propertyspecifications>\
+ <stringpropertyspecification name=\"state\" notr=\"true\" type=\"singleline\"/>\
+ </propertyspecifications>\
+ </customwidget>\
+ </customwidgets>\
</ui>");
}
diff --git a/examples/draganddrop/dropsite/dropsitewindow.cpp b/examples/draganddrop/dropsite/dropsitewindow.cpp
index 6e7055b..627baaa 100644
--- a/examples/draganddrop/dropsite/dropsitewindow.cpp
+++ b/examples/draganddrop/dropsite/dropsitewindow.cpp
@@ -119,10 +119,8 @@ void DropSiteWindow::updateFormatsTable(const QMimeData *mimeData)
text = mimeData->html().simplified();
} else if (format == "text/uri-list") {
QList<QUrl> urlList = mimeData->urls();
- for (int i = 0; i < urlList.size() && i < 32; ++i) {
- QString url = urlList.at(i).path();
- text.append(url + " ");
- }
+ for (int i = 0; i < urlList.size() && i < 32; ++i)
+ text.append(urlList[i].toString() + " ");
} else {
QByteArray data = mimeData->data(format);
for (int i = 0; i < data.size() && i < 32; ++i) {
diff --git a/examples/draganddrop/puzzle/mainwindow.cpp b/examples/draganddrop/puzzle/mainwindow.cpp
index f998882..9035442 100644
--- a/examples/draganddrop/puzzle/mainwindow.cpp
+++ b/examples/draganddrop/puzzle/mainwindow.cpp
@@ -120,10 +120,10 @@ void MainWindow::setupMenus()
QMenu *fileMenu = menuBar()->addMenu(tr("&File"));
QAction *openAction = fileMenu->addAction(tr("&Open..."));
- openAction->setShortcut(QKeySequence(tr("Ctrl+O")));
+ openAction->setShortcuts(QKeySequence::Open);
QAction *exitAction = fileMenu->addAction(tr("E&xit"));
- exitAction->setShortcut(QKeySequence(tr("Ctrl+Q")));
+ exitAction->setShortcuts(QKeySequence::Quit);
QMenu *gameMenu = menuBar()->addMenu(tr("&Game"));
diff --git a/examples/graphicsview/basicgraphicslayouts/layoutitem.cpp b/examples/graphicsview/basicgraphicslayouts/layoutitem.cpp
index 8216b6e..7311b65 100644
--- a/examples/graphicsview/basicgraphicslayouts/layoutitem.cpp
+++ b/examples/graphicsview/basicgraphicslayouts/layoutitem.cpp
@@ -43,19 +43,18 @@
//! [0]
LayoutItem::LayoutItem(QGraphicsItem *parent/* = 0*/)
- : QGraphicsWidget(parent)
+ : QGraphicsLayoutItem(), QGraphicsItem(parent)
{
- pix = new QPixmap(QLatin1String(":/images/block.png"));
- // Do not allow a size smaller than the pixmap with two frames around it.
- setMinimumSize(pix->size() + QSize(12, 12));
+ m_pix = new QPixmap(QLatin1String(":/images/block.png"));
+ setGraphicsItem(this);
}
//! [0]
LayoutItem::~LayoutItem()
{
- delete pix;
+ delete m_pix;
}
-
+
//! [1]
void LayoutItem::paint(QPainter *painter,
const QStyleOptionGraphicsItem *option, QWidget *widget /*= 0*/)
@@ -64,8 +63,8 @@ void LayoutItem::paint(QPainter *painter,
Q_UNUSED(option);
QRectF frame(QPointF(0,0), geometry().size());
- qreal w = pix->width();
- qreal h = pix->height();
+ qreal w = m_pix->width();
+ qreal h = m_pix->height();
QGradientStops stops;
//! [1]
@@ -94,6 +93,39 @@ void LayoutItem::paint(QPainter *painter,
gradient.setStops(stops);
painter->setBrush(QBrush(gradient));
painter->drawRoundedRect(innerFrame, 10.0, 10.0);
- painter->drawPixmap(pixpos, *pix);
+ painter->drawPixmap(pixpos, *m_pix);
}
//! [2]
+
+//! [3]
+QRectF LayoutItem::boundingRect() const
+{
+ return QRectF(QPointF(0,0), geometry().size());
+}
+//! [3]
+
+//! [4]
+void LayoutItem::setGeometry(const QRectF &geom)
+{
+ prepareGeometryChange();
+ QGraphicsLayoutItem::setGeometry(geom);
+ setPos(geom.topLeft());
+}
+//! [4]
+
+//! [5]
+QSizeF LayoutItem::sizeHint(Qt::SizeHint which, const QSizeF &constraint) const
+{
+ switch (which) {
+ case Qt::MinimumSize:
+ case Qt::PreferredSize:
+ // Do not allow a size smaller than the pixmap with two frames around it.
+ return m_pix->size() + QSize(12, 12);
+ case Qt::MaximumSize:
+ return QSizeF(1000,1000);
+ default:
+ break;
+ }
+ return constraint;
+}
+//! [5]
diff --git a/examples/graphicsview/basicgraphicslayouts/layoutitem.h b/examples/graphicsview/basicgraphicslayouts/layoutitem.h
index cbda636..8ec9038 100644
--- a/examples/graphicsview/basicgraphicslayouts/layoutitem.h
+++ b/examples/graphicsview/basicgraphicslayouts/layoutitem.h
@@ -44,18 +44,22 @@
#include <QtGui>
//! [0]
-class LayoutItem : public QGraphicsWidget
+class LayoutItem : public QGraphicsLayoutItem, public QGraphicsItem
{
- Q_OBJECT
-
public:
LayoutItem(QGraphicsItem *parent = 0);
~LayoutItem();
+ // Inherited from QGraphicsLayoutItem
+ void setGeometry(const QRectF &geom);
+ QSizeF sizeHint(Qt::SizeHint which, const QSizeF &constraint = QSizeF()) const;
+
+ // Inherited from QGraphicsItem
+ QRectF boundingRect() const;
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
QWidget *widget = 0);
private:
- QPixmap *pix;
+ QPixmap *m_pix;
};
//! [0]
diff --git a/examples/graphicsview/diagramscene/mainwindow.cpp b/examples/graphicsview/diagramscene/mainwindow.cpp
index b536a7a..78fac30 100644
--- a/examples/graphicsview/diagramscene/mainwindow.cpp
+++ b/examples/graphicsview/diagramscene/mainwindow.cpp
@@ -401,7 +401,7 @@ void MainWindow::createActions()
this, SLOT(deleteItem()));
exitAction = new QAction(tr("E&xit"), this);
- exitAction->setShortcut(tr("Ctrl+X"));
+ exitAction->setShortcuts(QKeySequence::Quit);
exitAction->setStatusTip(tr("Quit Scenediagram example"));
connect(exitAction, SIGNAL(triggered()), this, SLOT(close()));
diff --git a/examples/graphicsview/flowlayout/flowlayout.cpp b/examples/graphicsview/flowlayout/flowlayout.cpp
new file mode 100644
index 0000000..d36c37f
--- /dev/null
+++ b/examples/graphicsview/flowlayout/flowlayout.cpp
@@ -0,0 +1,210 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (qt-info@nokia.com)
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain
+** additional rights. These rights are described in the Nokia Qt LGPL
+** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "flowlayout.h"
+#include <QtGui/qwidget.h>
+#include <QtCore/qmath.h>
+
+FlowLayout::FlowLayout()
+{
+ m_spacing[0] = 6;
+ m_spacing[1] = 6;
+ QSizePolicy sp = sizePolicy();
+ sp.setHeightForWidth(true);
+ setSizePolicy(sp);
+}
+
+void FlowLayout::insertItem(int index, QGraphicsLayoutItem *item)
+{
+ item->setParentLayoutItem(this);
+ if (uint(index) > uint(m_items.count()))
+ index = m_items.count();
+ m_items.insert(index, item);
+ invalidate();
+}
+
+int FlowLayout::count() const
+{
+ return m_items.count();
+}
+
+QGraphicsLayoutItem *FlowLayout::itemAt(int index) const
+{
+ return m_items.value(index);
+}
+
+void FlowLayout::removeAt(int index)
+{
+ m_items.removeAt(index);
+ invalidate();
+}
+
+qreal FlowLayout::spacing(Qt::Orientation o) const
+{
+ return m_spacing[int(o) - 1];
+}
+
+void FlowLayout::setSpacing(Qt::Orientations o, qreal spacing)
+{
+ if (o & Qt::Horizontal)
+ m_spacing[0] = spacing;
+ if (o & Qt::Vertical)
+ m_spacing[1] = spacing;
+}
+
+void FlowLayout::setGeometry(const QRectF &geom)
+{
+ QGraphicsLayout::setGeometry(geom);
+ doLayout(geom, true);
+}
+
+qreal FlowLayout::doLayout(const QRectF &geom, bool applyNewGeometry) const
+{
+ QPointF tl = geom.topLeft();
+ qreal maxw = geom.width();
+
+ qreal left, top, right, bottom;
+ getContentsMargins(&left, &top, &right, &bottom);
+ maxw = maxw - left - right;
+ qreal x = 0;
+ qreal y = 0;
+ qreal maxRowHeight = 0;
+ QSizeF pref;
+ for (int i = 0; i < m_items.count(); ++i) {
+ QGraphicsLayoutItem *item = m_items.at(i);
+ pref = item->effectiveSizeHint(Qt::PreferredSize);
+ maxRowHeight = qMax(maxRowHeight, pref.height());
+
+ qreal next_x;
+ next_x = x + pref.width();
+ if (next_x > maxw) {
+ if (x == 0) {
+ pref.setWidth(maxw);
+ } else {
+ x = 0;
+ next_x = pref.width();
+ }
+ y += maxRowHeight + spacing(Qt::Vertical);
+ maxRowHeight = 0;
+ }
+
+ if (applyNewGeometry)
+ item->setGeometry(QRectF(QPointF(left + x, top + y), pref));
+ x = next_x + spacing(Qt::Horizontal);
+ }
+ maxRowHeight = qMax(maxRowHeight, pref.height());
+ return top + y + maxRowHeight + bottom;
+}
+
+QSizeF FlowLayout::minSize(const QSizeF &constraint) const
+{
+ QSizeF size(0, 0);
+ qreal left, top, right, bottom;
+ getContentsMargins(&left, &top, &right, &bottom);
+ if (constraint.width() > 0) { // height for width
+ qreal height = doLayout(QRectF(QPointF(0,0), constraint), false);
+ size = QSizeF(constraint.width(), height);
+ } else {
+ QGraphicsLayoutItem *item;
+ foreach (item, m_items)
+ size = size.expandedTo(item->effectiveSizeHint(Qt::MinimumSize));
+ size += QSize(left + right, top + bottom);
+ }
+ return size;
+}
+
+QSizeF FlowLayout::prefSize() const
+{
+ qreal left, top, right, bottom;
+ getContentsMargins(&left, &top, &right, &bottom);
+
+ QGraphicsLayoutItem *item;
+ qreal maxh = 0;
+ qreal totalWidth = 0;
+ foreach (item, m_items) {
+ if (totalWidth > 0)
+ totalWidth += spacing(Qt::Horizontal);
+ QSizeF pref = item->effectiveSizeHint(Qt::PreferredSize);
+ totalWidth += pref.width();
+ maxh = qMax(maxh, pref.height());
+ }
+ maxh += spacing(Qt::Vertical);
+
+ const qreal goldenAspectRatio = 1.61803399;
+ qreal w = qSqrt(totalWidth * maxh * goldenAspectRatio) + left + right;
+
+ return minSize(QSizeF(w, -1));
+}
+
+QSizeF FlowLayout::maxSize() const
+{
+ QGraphicsLayoutItem *item;
+ qreal totalWidth = 0;
+ qreal totalHeight = 0;
+ foreach (item, m_items) {
+ if (totalWidth > 0)
+ totalWidth += spacing(Qt::Horizontal);
+ if (totalHeight > 0)
+ totalHeight += spacing(Qt::Vertical);
+ QSizeF pref = item->effectiveSizeHint(Qt::PreferredSize);
+ totalWidth += pref.width();
+ totalHeight += pref.height();
+ }
+
+ qreal left, top, right, bottom;
+ getContentsMargins(&left, &top, &right, &bottom);
+ return QSizeF(left + totalWidth + right, top + totalHeight + bottom);
+}
+
+QSizeF FlowLayout::sizeHint(Qt::SizeHint which, const QSizeF &constraint) const
+{
+ switch (which) {
+ case Qt::PreferredSize:
+ return prefSize();
+ case Qt::MinimumSize:
+ return minSize(constraint);
+ case Qt::MaximumSize:
+ return maxSize();
+ default:
+ break;
+ }
+ return constraint;
+}
diff --git a/examples/graphicsview/flowlayout/flowlayout.h b/examples/graphicsview/flowlayout/flowlayout.h
new file mode 100644
index 0000000..c1e5635
--- /dev/null
+++ b/examples/graphicsview/flowlayout/flowlayout.h
@@ -0,0 +1,77 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (qt-info@nokia.com)
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain
+** additional rights. These rights are described in the Nokia Qt LGPL
+** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtGui/qgraphicslayout.h>
+
+class FlowLayout : public QGraphicsLayout
+{
+public:
+ FlowLayout();
+ inline void addItem(QGraphicsLayoutItem *item);
+ void insertItem(int index, QGraphicsLayoutItem *item);
+ void setSpacing(Qt::Orientations o, qreal spacing);
+ qreal spacing(Qt::Orientation o) const;
+
+ // inherited functions
+ void setGeometry(const QRectF &geom);
+
+ int count() const;
+ QGraphicsLayoutItem *itemAt(int index) const;
+ void removeAt(int index);
+
+protected:
+ QSizeF sizeHint(Qt::SizeHint which, const QSizeF &constraint = QSizeF()) const;
+
+private:
+ qreal doLayout(const QRectF &geom, bool applyNewGeometry) const;
+ QSizeF minSize(const QSizeF &constraint) const;
+ QSizeF prefSize() const;
+ QSizeF maxSize() const;
+
+ QList<QGraphicsLayoutItem*> m_items;
+ qreal m_spacing[2];
+};
+
+
+inline void FlowLayout::addItem(QGraphicsLayoutItem *item)
+{
+ insertItem(-1, item);
+}
diff --git a/examples/graphicsview/flowlayout/flowlayout.pro b/examples/graphicsview/flowlayout/flowlayout.pro
new file mode 100644
index 0000000..c029d6c
--- /dev/null
+++ b/examples/graphicsview/flowlayout/flowlayout.pro
@@ -0,0 +1,12 @@
+######################################################################
+# Automatically generated by qmake (2.01a) ma 30. mar 12:46:15 2009
+######################################################################
+
+TEMPLATE = app
+TARGET =
+DEPENDPATH += .
+INCLUDEPATH += .
+
+# Input
+HEADERS += flowlayout.h window.h
+SOURCES += flowlayout.cpp main.cpp window.cpp
diff --git a/examples/graphicsview/flowlayout/main.cpp b/examples/graphicsview/flowlayout/main.cpp
new file mode 100644
index 0000000..d1a40c7
--- /dev/null
+++ b/examples/graphicsview/flowlayout/main.cpp
@@ -0,0 +1,55 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (qt-info@nokia.com)
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain
+** additional rights. These rights are described in the Nokia Qt LGPL
+** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtGui>
+#include "window.h"
+
+int main(int argc, char **argv)
+{
+ QApplication app(argc, argv);
+
+ QGraphicsScene scene;
+ QGraphicsView *view = new QGraphicsView(&scene);
+ Window *w = new Window;
+ scene.addItem(w);
+ view->show();
+ return app.exec();
+}
diff --git a/examples/graphicsview/flowlayout/window.cpp b/examples/graphicsview/flowlayout/window.cpp
new file mode 100644
index 0000000..dd53b56
--- /dev/null
+++ b/examples/graphicsview/flowlayout/window.cpp
@@ -0,0 +1,63 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (qt-info@nokia.com)
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain
+** additional rights. These rights are described in the Nokia Qt LGPL
+** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtGui/qgraphicsproxywidget.h>
+#include <QtGui/qlabel.h>
+#include "flowlayout.h"
+#include "window.h"
+
+Window::Window()
+: QGraphicsWidget(0, Qt::Window)
+{
+ FlowLayout *lay = new FlowLayout;
+ QLatin1String wiseWords("I am not bothered by the fact that I am unknown."
+ "I am bothered when I do not know others. (Confucius)");
+ QString sentence(wiseWords);
+ QStringList words = sentence.split(QLatin1Char(' '), QString::SkipEmptyParts);
+ for (int i = 0; i < words.count(); ++i) {
+ QGraphicsProxyWidget *proxy = new QGraphicsProxyWidget(this);
+ QLabel *label = new QLabel(words.at(i));
+ label->setFrameStyle(QFrame::Box | QFrame::Plain);
+ proxy->setWidget(label);
+ lay->addItem(proxy);
+ }
+ setLayout(lay);
+}
diff --git a/examples/graphicsview/flowlayout/window.h b/examples/graphicsview/flowlayout/window.h
new file mode 100644
index 0000000..6d315f5
--- /dev/null
+++ b/examples/graphicsview/flowlayout/window.h
@@ -0,0 +1,48 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (qt-info@nokia.com)
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain
+** additional rights. These rights are described in the Nokia Qt LGPL
+** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtGui/qgraphicswidget.h>
+
+class Window : public QGraphicsWidget {
+ Q_OBJECT
+public:
+ Window();
+};
diff --git a/examples/graphicsview/padnavigator/roundrectitem.cpp b/examples/graphicsview/padnavigator/roundrectitem.cpp
index ec91966..73d6d33 100644
--- a/examples/graphicsview/padnavigator/roundrectitem.cpp
+++ b/examples/graphicsview/padnavigator/roundrectitem.cpp
@@ -115,10 +115,9 @@ void RoundRectItem::keyPressEvent(QKeyEvent *event)
return;
}
- if (!proxyWidget) {
- setXScale(qreal(.9));
- setYScale(qreal(.9));
- }
+ if (!proxyWidget)
+ setScale(qreal(.9), qreal(.9));
+
emit activated();
}
@@ -129,8 +128,6 @@ void RoundRectItem::keyReleaseEvent(QKeyEvent *event)
return;
}
- if (!proxyWidget) {
- setXScale(1);
- setYScale(1);
- }
+ if (!proxyWidget)
+ setScale(1, 1);
}
diff --git a/examples/help/simpletextviewer/mainwindow.cpp b/examples/help/simpletextviewer/mainwindow.cpp
index fc9af58..33092ca 100644
--- a/examples/help/simpletextviewer/mainwindow.cpp
+++ b/examples/help/simpletextviewer/mainwindow.cpp
@@ -102,12 +102,12 @@ void MainWindow::open()
void MainWindow::createActions()
{
assistantAct = new QAction(tr("Help Contents"), this);
- assistantAct->setShortcut(tr("F1"));
+ assistantAct->setShortcut(QKeySequence::HelpContents);
connect(assistantAct, SIGNAL(triggered()), this, SLOT(showDocumentation()));
//! [4]
openAct = new QAction(tr("&Open..."), this);
- openAct->setShortcut(tr("Ctrl+O"));
+ openAct->setShortcut(QKeySequence::Open);
connect(openAct, SIGNAL(triggered()), this, SLOT(open()));
clearAct = new QAction(tr("&Clear"), this);
@@ -115,7 +115,7 @@ void MainWindow::createActions()
connect(clearAct, SIGNAL(triggered()), textViewer, SLOT(clear()));
exitAct = new QAction(tr("E&xit"), this);
- exitAct->setShortcut(tr("Ctrl+Q"));
+ exitAct->setShortcuts(QKeySequence::Quit);
connect(exitAct, SIGNAL(triggered()), this, SLOT(close()));
aboutAct = new QAction(tr("&About"), this);
diff --git a/examples/itemviews/chart/mainwindow.cpp b/examples/itemviews/chart/mainwindow.cpp
index 208a465..d065558 100644
--- a/examples/itemviews/chart/mainwindow.cpp
+++ b/examples/itemviews/chart/mainwindow.cpp
@@ -48,11 +48,11 @@ MainWindow::MainWindow()
{
QMenu *fileMenu = new QMenu(tr("&File"), this);
QAction *openAction = fileMenu->addAction(tr("&Open..."));
- openAction->setShortcut(QKeySequence(tr("Ctrl+O")));
+ openAction->setShortcuts(QKeySequence::Open);
QAction *saveAction = fileMenu->addAction(tr("&Save As..."));
- saveAction->setShortcut(QKeySequence(tr("Ctrl+S")));
+ saveAction->setShortcuts(QKeySequence::SaveAs);
QAction *quitAction = fileMenu->addAction(tr("E&xit"));
- quitAction->setShortcut(QKeySequence(tr("Ctrl+Q")));
+ quitAction->setShortcuts(QKeySequence::Quit);
setupModel();
setupViews();
diff --git a/examples/itemviews/pixelator/mainwindow.cpp b/examples/itemviews/pixelator/mainwindow.cpp
index a2b98cf..80cfc5c 100644
--- a/examples/itemviews/pixelator/mainwindow.cpp
+++ b/examples/itemviews/pixelator/mainwindow.cpp
@@ -79,14 +79,14 @@ MainWindow::MainWindow()
QMenu *fileMenu = new QMenu(tr("&File"), this);
QAction *openAction = fileMenu->addAction(tr("&Open..."));
- openAction->setShortcut(QKeySequence(tr("Ctrl+O")));
+ openAction->setShortcuts(QKeySequence::Open);
printAction = fileMenu->addAction(tr("&Print..."));
printAction->setEnabled(false);
- printAction->setShortcut(QKeySequence(tr("Ctrl+P")));
+ printAction->setShortcut(QKeySequence::Print);
QAction *quitAction = fileMenu->addAction(tr("E&xit"));
- quitAction->setShortcut(QKeySequence(tr("Ctrl+Q")));
+ quitAction->setShortcuts(QKeySequence::Quit);
QMenu *helpMenu = new QMenu(tr("&Help"), this);
QAction *aboutAction = helpMenu->addAction(tr("&About"));
diff --git a/examples/itemviews/puzzle/mainwindow.cpp b/examples/itemviews/puzzle/mainwindow.cpp
index c6088f6..a5ba236 100644
--- a/examples/itemviews/puzzle/mainwindow.cpp
+++ b/examples/itemviews/puzzle/mainwindow.cpp
@@ -107,10 +107,10 @@ void MainWindow::setupMenus()
QMenu *fileMenu = menuBar()->addMenu(tr("&File"));
QAction *openAction = fileMenu->addAction(tr("&Open..."));
- openAction->setShortcut(QKeySequence(tr("Ctrl+O")));
+ openAction->setShortcuts(QKeySequence::Open);
QAction *exitAction = fileMenu->addAction(tr("E&xit"));
- exitAction->setShortcut(QKeySequence(tr("Ctrl+Q")));
+ exitAction->setShortcuts(QKeySequence::Quit);
QMenu *gameMenu = menuBar()->addMenu(tr("&Game"));
diff --git a/examples/itemviews/simpledommodel/mainwindow.cpp b/examples/itemviews/simpledommodel/mainwindow.cpp
index ac96899..73626b1 100644
--- a/examples/itemviews/simpledommodel/mainwindow.cpp
+++ b/examples/itemviews/simpledommodel/mainwindow.cpp
@@ -50,9 +50,9 @@ MainWindow::MainWindow() : QMainWindow(), model(0)
{
fileMenu = menuBar()->addMenu(tr("&File"));
fileMenu->addAction(tr("&Open..."), this, SLOT(openFile()),
- QKeySequence(tr("Ctrl+O")));
+ QKeySequence::Open);
fileMenu->addAction(tr("E&xit"), this, SLOT(close()),
- QKeySequence(tr("Ctrl+Q")));
+ QKeySequence::Quit);
model = new DomModel(QDomDocument(), this);
view = new QTreeView(this);
diff --git a/examples/linguist/arrowpad/mainwindow.cpp b/examples/linguist/arrowpad/mainwindow.cpp
index a167cc2..37b9362 100644
--- a/examples/linguist/arrowpad/mainwindow.cpp
+++ b/examples/linguist/arrowpad/mainwindow.cpp
@@ -53,7 +53,7 @@ MainWindow::MainWindow()
//! [1]
exitAct = new QAction(tr("E&xit"), this);
- exitAct->setShortcut(tr("Ctrl+Q"));
+ exitAct->setShortcuts(QKeySequence::Quit);
connect(exitAct, SIGNAL(triggered()), this, SLOT(close()));
//! [1]
diff --git a/examples/mainwindows/application/mainwindow.cpp b/examples/mainwindows/application/mainwindow.cpp
index 9a22254..cf36332 100644
--- a/examples/mainwindows/application/mainwindow.cpp
+++ b/examples/mainwindows/application/mainwindow.cpp
@@ -174,7 +174,7 @@ void MainWindow::createActions()
//! [20]
exitAct = new QAction(tr("E&xit"), this);
- exitAct->setShortcut(tr("Ctrl+Q"));
+ exitAct->setShortcuts(QKeySequence::Quit);
//! [20]
exitAct->setStatusTip(tr("Exit the application"));
connect(exitAct, SIGNAL(triggered()), this, SLOT(close()));
diff --git a/examples/mainwindows/dockwidgets/mainwindow.cpp b/examples/mainwindows/dockwidgets/mainwindow.cpp
index 1683034..4ccd2f1 100644
--- a/examples/mainwindows/dockwidgets/mainwindow.cpp
+++ b/examples/mainwindows/dockwidgets/mainwindow.cpp
@@ -242,7 +242,7 @@ void MainWindow::createActions()
connect(undoAct, SIGNAL(triggered()), this, SLOT(undo()));
quitAct = new QAction(tr("&Quit"), this);
- quitAct->setShortcut(tr("Ctrl+Q"));
+ quitAct->setShortcuts(QKeySequence::Quit);
quitAct->setStatusTip(tr("Quit the application"));
connect(quitAct, SIGNAL(triggered()), this, SLOT(close()));
diff --git a/examples/mainwindows/mdi/mainwindow.cpp b/examples/mainwindows/mdi/mainwindow.cpp
index 49f9b21..e6e3e6e 100644
--- a/examples/mainwindows/mdi/mainwindow.cpp
+++ b/examples/mainwindows/mdi/mainwindow.cpp
@@ -235,7 +235,7 @@ void MainWindow::createActions()
//! [0]
exitAct = new QAction(tr("E&xit"), this);
- exitAct->setShortcut(tr("Ctrl+Q"));
+ exitAct->setShortcuts(QKeySequence::Quit);
exitAct->setStatusTip(tr("Exit the application"));
connect(exitAct, SIGNAL(triggered()), qApp, SLOT(closeAllWindows()));
//! [0]
diff --git a/examples/mainwindows/menus/mainwindow.cpp b/examples/mainwindows/menus/mainwindow.cpp
index 4c10f73..08a3c31 100644
--- a/examples/mainwindows/menus/mainwindow.cpp
+++ b/examples/mainwindows/menus/mainwindow.cpp
@@ -219,7 +219,7 @@ void MainWindow::createActions()
connect(printAct, SIGNAL(triggered()), this, SLOT(print()));
exitAct = new QAction(tr("E&xit"), this);
- exitAct->setShortcut(tr("Ctrl+Q"));
+ exitAct->setShortcuts(QKeySequence::Quit);
exitAct->setStatusTip(tr("Exit the application"));
connect(exitAct, SIGNAL(triggered()), this, SLOT(close()));
@@ -240,7 +240,7 @@ void MainWindow::createActions()
connect(cutAct, SIGNAL(triggered()), this, SLOT(cut()));
copyAct = new QAction(tr("&Copy"), this);
- copyAct->setShortcut(tr("Ctrl+C"));
+ copyAct->setShortcuts(QKeySequence::Copy);
copyAct->setStatusTip(tr("Copy the current selection's contents to the "
"clipboard"));
connect(copyAct, SIGNAL(triggered()), this, SLOT(copy()));
@@ -253,7 +253,7 @@ void MainWindow::createActions()
boldAct = new QAction(tr("&Bold"), this);
boldAct->setCheckable(true);
- boldAct->setShortcut(tr("Ctrl+B"));
+ boldAct->setShortcut(QKeySequence::Bold);
boldAct->setStatusTip(tr("Make the text bold"));
connect(boldAct, SIGNAL(triggered()), this, SLOT(bold()));
@@ -263,7 +263,7 @@ void MainWindow::createActions()
italicAct = new QAction(tr("&Italic"), this);
italicAct->setCheckable(true);
- italicAct->setShortcut(tr("Ctrl+I"));
+ italicAct->setShortcut(QKeySequence::Italic);
italicAct->setStatusTip(tr("Make the text italic"));
connect(italicAct, SIGNAL(triggered()), this, SLOT(italic()));
diff --git a/examples/mainwindows/recentfiles/mainwindow.cpp b/examples/mainwindows/recentfiles/mainwindow.cpp
index c8c2f88..5746863 100644
--- a/examples/mainwindows/recentfiles/mainwindow.cpp
+++ b/examples/mainwindows/recentfiles/mainwindow.cpp
@@ -132,7 +132,7 @@ void MainWindow::createActions()
}
exitAct = new QAction(tr("E&xit"), this);
- exitAct->setShortcut(tr("Ctrl+Q"));
+ exitAct->setShortcuts(QKeySequence::Quit);
exitAct->setStatusTip(tr("Exit the application"));
connect(exitAct, SIGNAL(triggered()), qApp, SLOT(closeAllWindows()));
diff --git a/examples/mainwindows/sdi/mainwindow.cpp b/examples/mainwindows/sdi/mainwindow.cpp
index 61d63b3..e7e05ee 100644
--- a/examples/mainwindows/sdi/mainwindow.cpp
+++ b/examples/mainwindows/sdi/mainwindow.cpp
@@ -180,7 +180,7 @@ void MainWindow::createActions()
connect(closeAct, SIGNAL(triggered()), this, SLOT(close()));
exitAct = new QAction(tr("E&xit"), this);
- exitAct->setShortcut(tr("Ctrl+Q"));
+ exitAct->setShortcuts(QKeySequence::Quit);
exitAct->setStatusTip(tr("Exit the application"));
connect(exitAct, SIGNAL(triggered()), qApp, SLOT(closeAllWindows()));
diff --git a/examples/opengl/grabber/mainwindow.cpp b/examples/opengl/grabber/mainwindow.cpp
index 7e878f9..9e27023 100644
--- a/examples/opengl/grabber/mainwindow.cpp
+++ b/examples/opengl/grabber/mainwindow.cpp
@@ -136,7 +136,7 @@ void MainWindow::createActions()
connect(clearPixmapAct, SIGNAL(triggered()), this, SLOT(clearPixmap()));
exitAct = new QAction(tr("E&xit"), this);
- exitAct->setShortcut(tr("Ctrl+Q"));
+ exitAct->setShortcuts(QKeySequence::Quit);
connect(exitAct, SIGNAL(triggered()), this, SLOT(close()));
aboutAct = new QAction(tr("&About"), this);
diff --git a/examples/painting/svgviewer/mainwindow.cpp b/examples/painting/svgviewer/mainwindow.cpp
index 22393eb..64f35ed 100644
--- a/examples/painting/svgviewer/mainwindow.cpp
+++ b/examples/painting/svgviewer/mainwindow.cpp
@@ -53,7 +53,7 @@ MainWindow::MainWindow()
QAction *openAction = fileMenu->addAction(tr("&Open..."));
openAction->setShortcut(QKeySequence(tr("Ctrl+O")));
QAction *quitAction = fileMenu->addAction(tr("E&xit"));
- quitAction->setShortcut(QKeySequence(tr("Ctrl+Q")));
+ quitAction->setShortcuts(QKeySequence::Quit);
menuBar()->addMenu(fileMenu);
diff --git a/examples/phonon/musicplayer/mainwindow.cpp b/examples/phonon/musicplayer/mainwindow.cpp
index f50a2bd..30c6d05 100644
--- a/examples/phonon/musicplayer/mainwindow.cpp
+++ b/examples/phonon/musicplayer/mainwindow.cpp
@@ -261,7 +261,7 @@ void MainWindow::setupActions()
addFilesAction = new QAction(tr("Add &Files"), this);
addFilesAction->setShortcut(tr("Ctrl+F"));
exitAction = new QAction(tr("E&xit"), this);
- exitAction->setShortcut(tr("Ctrl+X"));
+ exitAction->setShortcuts(QKeySequence::Quit);
aboutAction = new QAction(tr("A&bout"), this);
aboutAction->setShortcut(tr("Ctrl+B"));
aboutQtAction = new QAction(tr("About &Qt"), this);
diff --git a/examples/richtext/orderform/mainwindow.cpp b/examples/richtext/orderform/mainwindow.cpp
index e5cffe3..7e460b7 100644
--- a/examples/richtext/orderform/mainwindow.cpp
+++ b/examples/richtext/orderform/mainwindow.cpp
@@ -49,12 +49,12 @@ MainWindow::MainWindow()
{
QMenu *fileMenu = new QMenu(tr("&File"), this);
QAction *newAction = fileMenu->addAction(tr("&New..."));
- newAction->setShortcut(tr("Ctrl+N"));
+ newAction->setShortcuts(QKeySequence::New);
printAction = fileMenu->addAction(tr("&Print..."), this, SLOT(printFile()));
- printAction->setShortcut(tr("Ctrl+P"));
+ printAction->setShortcuts(QKeySequence::Print);
printAction->setEnabled(false);
QAction *quitAction = fileMenu->addAction(tr("E&xit"));
- quitAction->setShortcut(tr("Ctrl+Q"));
+ quitAction->setShortcuts(QKeySequence::Quit);
menuBar()->addMenu(fileMenu);
letters = new QTabWidget;
diff --git a/examples/richtext/syntaxhighlighter/mainwindow.cpp b/examples/richtext/syntaxhighlighter/mainwindow.cpp
index a6312f9..0d1b41f 100644
--- a/examples/richtext/syntaxhighlighter/mainwindow.cpp
+++ b/examples/richtext/syntaxhighlighter/mainwindow.cpp
@@ -110,14 +110,13 @@ void MainWindow::setupFileMenu()
menuBar()->addMenu(fileMenu);
fileMenu->addAction(tr("&New"), this, SLOT(newFile()),
- QKeySequence(tr("Ctrl+N",
- "File|New")));
+ QKeySequence::New);
+
fileMenu->addAction(tr("&Open..."), this, SLOT(openFile()),
- QKeySequence(tr("Ctrl+O",
- "File|Open")));
+ QKeySequence::Open);
+
fileMenu->addAction(tr("E&xit"), qApp, SLOT(quit()),
- QKeySequence(tr("Ctrl+Q",
- "File|Exit")));
+ QKeySequence::Quit);
}
void MainWindow::setupHelpMenu()
diff --git a/examples/sql/masterdetail/mainwindow.cpp b/examples/sql/masterdetail/mainwindow.cpp
index 67825d6..5bf4cb9 100644
--- a/examples/sql/masterdetail/mainwindow.cpp
+++ b/examples/sql/masterdetail/mainwindow.cpp
@@ -362,7 +362,7 @@ void MainWindow::createMenuBar()
addAction->setShortcut(tr("Ctrl+A"));
deleteAction->setShortcut(tr("Ctrl+D"));
- quitAction->setShortcut(tr("Ctrl+Q"));
+ quitAction->setShortcuts(QKeySequence::Quit);
QMenu *fileMenu = menuBar()->addMenu(tr("&File"));
fileMenu->addAction(addAction);
diff --git a/examples/tools/codecs/mainwindow.cpp b/examples/tools/codecs/mainwindow.cpp
index 1e6fa69..5d3b7ac 100644
--- a/examples/tools/codecs/mainwindow.cpp
+++ b/examples/tools/codecs/mainwindow.cpp
@@ -156,7 +156,7 @@ void MainWindow::findCodecs()
void MainWindow::createActions()
{
openAct = new QAction(tr("&Open..."), this);
- openAct->setShortcut(tr("Ctrl+O"));
+ openAct->setShortcuts(QKeySequence::Open);
connect(openAct, SIGNAL(triggered()), this, SLOT(open()));
foreach (QTextCodec *codec, codecs) {
@@ -169,7 +169,7 @@ void MainWindow::createActions()
}
exitAct = new QAction(tr("E&xit"), this);
- exitAct->setShortcut(tr("Ctrl+Q"));
+ exitAct->setShortcuts(QKeySequence::Quit);
connect(exitAct, SIGNAL(triggered()), this, SLOT(close()));
aboutAct = new QAction(tr("&About"), this);
diff --git a/examples/tools/contiguouscache/contiguouscache.pro b/examples/tools/contiguouscache/contiguouscache.pro
new file mode 100644
index 0000000..f840514
--- /dev/null
+++ b/examples/tools/contiguouscache/contiguouscache.pro
@@ -0,0 +1,9 @@
+HEADERS = randomlistmodel.h
+SOURCES = randomlistmodel.cpp \
+ main.cpp
+
+# install
+target.path = $$[QT_INSTALL_EXAMPLES]/tools/contiguouscache
+sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS contiguouscache.pro
+sources.path = $$[QT_INSTALL_EXAMPLES]/tools/contiguouscache
+INSTALLS += target sources
diff --git a/examples/tools/contiguouscache/main.cpp b/examples/tools/contiguouscache/main.cpp
new file mode 100644
index 0000000..291aaf4
--- /dev/null
+++ b/examples/tools/contiguouscache/main.cpp
@@ -0,0 +1,56 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (qt-info@nokia.com)
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain
+** additional rights. These rights are described in the Nokia Qt LGPL
+** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "randomlistmodel.h"
+#include <QListView>
+#include <QApplication>
+
+int main(int c, char **v)
+{
+ QApplication a(c, v);
+
+ QListView view;
+ view.setUniformItemSizes(true);
+ view.setModel(new RandomListModel(&view));
+ view.show();
+
+ return a.exec();
+}
diff --git a/examples/tools/contiguouscache/randomlistmodel.cpp b/examples/tools/contiguouscache/randomlistmodel.cpp
new file mode 100644
index 0000000..b1c7204
--- /dev/null
+++ b/examples/tools/contiguouscache/randomlistmodel.cpp
@@ -0,0 +1,97 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (qt-info@nokia.com)
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain
+** additional rights. These rights are described in the Nokia Qt LGPL
+** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include "randomlistmodel.h"
+#include <stdlib.h>
+
+static const int bufferSize(500);
+static const int lookAhead(100);
+static const int halfLookAhead(lookAhead/2);
+
+RandomListModel::RandomListModel(QObject *parent)
+: QAbstractListModel(parent), m_rows(bufferSize), m_count(10000)
+{
+}
+
+RandomListModel::~RandomListModel()
+{
+}
+
+int RandomListModel::rowCount(const QModelIndex &) const
+{
+ return m_count;
+}
+
+//! [0]
+QVariant RandomListModel::data(const QModelIndex &index, int role) const
+{
+ if (role != Qt::DisplayRole)
+ return QVariant();
+
+ int row = index.row();
+
+ if (row > m_rows.lastIndex()) {
+ if (row - m_rows.lastIndex() > lookAhead)
+ cacheRows(row-halfLookAhead, qMin(m_count, row+halfLookAhead));
+ else while (row > m_rows.lastIndex())
+ m_rows.append(fetchRow(m_rows.lastIndex()+1));
+ } else if (row < m_rows.firstIndex()) {
+ if (m_rows.firstIndex() - row > lookAhead)
+ cacheRows(qMax(0, row-halfLookAhead), row+halfLookAhead);
+ else while (row < m_rows.firstIndex())
+ m_rows.prepend(fetchRow(m_rows.firstIndex()-1));
+ }
+
+ return m_rows.at(row);
+}
+
+void RandomListModel::cacheRows(int from, int to) const
+{
+ for (int i = from; i <= to; ++i)
+ m_rows.insert(i, fetchRow(i));
+}
+//![0]
+
+//![1]
+QString RandomListModel::fetchRow(int position) const
+{
+ return QString::number(rand() % ++position);
+}
+//![1]
diff --git a/examples/tools/contiguouscache/randomlistmodel.h b/examples/tools/contiguouscache/randomlistmodel.h
new file mode 100644
index 0000000..d32bf16
--- /dev/null
+++ b/examples/tools/contiguouscache/randomlistmodel.h
@@ -0,0 +1,66 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (qt-info@nokia.com)
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain
+** additional rights. These rights are described in the Nokia Qt LGPL
+** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#ifndef RANDOMLISTMODEL_H
+#define RANDOMLISTMODEL_H
+
+#include <QContiguousCache>
+#include <QAbstractListModel>
+
+class QTimer;
+class RandomListModel : public QAbstractListModel
+{
+ Q_OBJECT
+public:
+ RandomListModel(QObject *parent = 0);
+ ~RandomListModel();
+
+ int rowCount(const QModelIndex & = QModelIndex()) const;
+ QVariant data(const QModelIndex &, int) const;
+
+private:
+ void cacheRows(int, int) const;
+ QString fetchRow(int) const;
+
+ mutable QContiguousCache<QString> m_rows;
+ const int m_count;
+};
+
+#endif
diff --git a/examples/tools/plugandpaint/mainwindow.cpp b/examples/tools/plugandpaint/mainwindow.cpp
index 224bc71..f61359b 100644
--- a/examples/tools/plugandpaint/mainwindow.cpp
+++ b/examples/tools/plugandpaint/mainwindow.cpp
@@ -179,15 +179,15 @@ void MainWindow::aboutPlugins()
void MainWindow::createActions()
{
openAct = new QAction(tr("&Open..."), this);
- openAct->setShortcut(tr("Ctrl+O"));
+ openAct->setShortcuts(QKeySequence::Open);
connect(openAct, SIGNAL(triggered()), this, SLOT(open()));
saveAsAct = new QAction(tr("&Save As..."), this);
- saveAsAct->setShortcut(tr("Ctrl+S"));
+ saveAsAct->setShortcuts(QKeySequence::SaveAs);
connect(saveAsAct, SIGNAL(triggered()), this, SLOT(saveAs()));
exitAct = new QAction(tr("E&xit"), this);
- exitAct->setShortcut(tr("Ctrl+Q"));
+ exitAct->setShortcuts(QKeySequence::Quit);
connect(exitAct, SIGNAL(triggered()), this, SLOT(close()));
brushColorAct = new QAction(tr("&Brush Color..."), this);
diff --git a/examples/tools/settingseditor/mainwindow.cpp b/examples/tools/settingseditor/mainwindow.cpp
index 0f48a5c..0321b55 100644
--- a/examples/tools/settingseditor/mainwindow.cpp
+++ b/examples/tools/settingseditor/mainwindow.cpp
@@ -122,7 +122,7 @@ void MainWindow::about()
void MainWindow::createActions()
{
openSettingsAct = new QAction(tr("&Open Application Settings..."), this);
- openSettingsAct->setShortcut(tr("Ctrl+O"));
+ openSettingsAct->setShortcuts(QKeySequence::Open);
connect(openSettingsAct, SIGNAL(triggered()), this, SLOT(openSettings()));
openIniFileAct = new QAction(tr("Open I&NI File..."), this);
@@ -146,7 +146,7 @@ void MainWindow::createActions()
connect(refreshAct, SIGNAL(triggered()), settingsTree, SLOT(refresh()));
exitAct = new QAction(tr("E&xit"), this);
- exitAct->setShortcut(tr("Ctrl+Q"));
+ exitAct->setShortcuts(QKeySequence::Quit);
connect(exitAct, SIGNAL(triggered()), this, SLOT(close()));
autoRefreshAct = new QAction(tr("&Auto-Refresh"), this);
diff --git a/examples/tools/tools.pro b/examples/tools/tools.pro
index 79f0faa..c694dd8 100644
--- a/examples/tools/tools.pro
+++ b/examples/tools/tools.pro
@@ -5,6 +5,7 @@ SUBDIRS = codecs \
customcompleter \
echoplugin \
i18n \
+ contiguouscache \
plugandpaintplugins \
plugandpaint \
regexp \
diff --git a/examples/tools/undoframework/mainwindow.cpp b/examples/tools/undoframework/mainwindow.cpp
index f912ff2..bf0aa41 100644
--- a/examples/tools/undoframework/mainwindow.cpp
+++ b/examples/tools/undoframework/mainwindow.cpp
@@ -101,16 +101,14 @@ void MainWindow::createActions()
//! [5]
undoAction = undoStack->createUndoAction(this, tr("&Undo"));
- undoAction->setShortcut(tr("Ctrl+Z"));
+ undoAction->setShortcuts(QKeySequence::Undo);
redoAction = undoStack->createRedoAction(this, tr("&Redo"));
- QList<QKeySequence> redoShortcuts;
- redoShortcuts << tr("Ctrl+Y") << tr("Shift+Ctrl+Z");
- redoAction->setShortcuts(redoShortcuts);
+ redoAction->setShortcuts(QKeySequence::Redo);
//! [5]
exitAction = new QAction(tr("E&xit"), this);
- exitAction->setShortcut(tr("Ctrl+Q"));
+ exitAction->setShortcuts(QKeySequence::Quit);
connect(exitAction, SIGNAL(triggered()), this, SLOT(close()));
aboutAction = new QAction(tr("&About"), this);
diff --git a/examples/tutorials/addressbook-fr/part1/main.cpp b/examples/tutorials/addressbook-fr/part1/main.cpp
index 22bfd3e..9c96882 100644
--- a/examples/tutorials/addressbook-fr/part1/main.cpp
+++ b/examples/tutorials/addressbook-fr/part1/main.cpp
@@ -47,8 +47,8 @@ int main(int argc, char *argv[])
{
QApplication app(argc, argv);
- AddressBook *addressBook = new AddressBook;
- addressBook->show();
+ AddressBook addressBook;
+ addressBook.show();
return app.exec();
}
diff --git a/examples/tutorials/addressbook-fr/part2/main.cpp b/examples/tutorials/addressbook-fr/part2/main.cpp
index 22bfd3e..9c96882 100644
--- a/examples/tutorials/addressbook-fr/part2/main.cpp
+++ b/examples/tutorials/addressbook-fr/part2/main.cpp
@@ -47,8 +47,8 @@ int main(int argc, char *argv[])
{
QApplication app(argc, argv);
- AddressBook *addressBook = new AddressBook;
- addressBook->show();
+ AddressBook addressBook;
+ addressBook.show();
return app.exec();
}
diff --git a/examples/tutorials/addressbook-fr/part3/main.cpp b/examples/tutorials/addressbook-fr/part3/main.cpp
index b25d656..46f6f03 100644
--- a/examples/tutorials/addressbook-fr/part3/main.cpp
+++ b/examples/tutorials/addressbook-fr/part3/main.cpp
@@ -46,8 +46,8 @@ int main(int argc, char *argv[])
{
QApplication app(argc, argv);
- AddressBook *addressBook = new AddressBook;
- addressBook->show();
+ AddressBook addressBook;
+ addressBook.show();
return app.exec();
}
diff --git a/examples/tutorials/addressbook-fr/part4/main.cpp b/examples/tutorials/addressbook-fr/part4/main.cpp
index b25d656..46f6f03 100644
--- a/examples/tutorials/addressbook-fr/part4/main.cpp
+++ b/examples/tutorials/addressbook-fr/part4/main.cpp
@@ -46,8 +46,8 @@ int main(int argc, char *argv[])
{
QApplication app(argc, argv);
- AddressBook *addressBook = new AddressBook;
- addressBook->show();
+ AddressBook addressBook;
+ addressBook.show();
return app.exec();
}
diff --git a/examples/tutorials/addressbook-fr/part5/main.cpp b/examples/tutorials/addressbook-fr/part5/main.cpp
index b25d656..46f6f03 100644
--- a/examples/tutorials/addressbook-fr/part5/main.cpp
+++ b/examples/tutorials/addressbook-fr/part5/main.cpp
@@ -46,8 +46,8 @@ int main(int argc, char *argv[])
{
QApplication app(argc, argv);
- AddressBook *addressBook = new AddressBook;
- addressBook->show();
+ AddressBook addressBook;
+ addressBook.show();
return app.exec();
}
diff --git a/examples/tutorials/addressbook-fr/part6/main.cpp b/examples/tutorials/addressbook-fr/part6/main.cpp
index b25d656..46f6f03 100644
--- a/examples/tutorials/addressbook-fr/part6/main.cpp
+++ b/examples/tutorials/addressbook-fr/part6/main.cpp
@@ -46,8 +46,8 @@ int main(int argc, char *argv[])
{
QApplication app(argc, argv);
- AddressBook *addressBook = new AddressBook;
- addressBook->show();
+ AddressBook addressBook;
+ addressBook.show();
return app.exec();
}
diff --git a/examples/tutorials/addressbook-fr/part7/main.cpp b/examples/tutorials/addressbook-fr/part7/main.cpp
index b25d656..46f6f03 100644
--- a/examples/tutorials/addressbook-fr/part7/main.cpp
+++ b/examples/tutorials/addressbook-fr/part7/main.cpp
@@ -46,8 +46,8 @@ int main(int argc, char *argv[])
{
QApplication app(argc, argv);
- AddressBook *addressBook = new AddressBook;
- addressBook->show();
+ AddressBook addressBook;
+ addressBook.show();
return app.exec();
}
diff --git a/examples/tutorials/addressbook/part1/main.cpp b/examples/tutorials/addressbook/part1/main.cpp
index 22bfd3e..9c96882 100644
--- a/examples/tutorials/addressbook/part1/main.cpp
+++ b/examples/tutorials/addressbook/part1/main.cpp
@@ -47,8 +47,8 @@ int main(int argc, char *argv[])
{
QApplication app(argc, argv);
- AddressBook *addressBook = new AddressBook;
- addressBook->show();
+ AddressBook addressBook;
+ addressBook.show();
return app.exec();
}
diff --git a/examples/tutorials/addressbook/part2/main.cpp b/examples/tutorials/addressbook/part2/main.cpp
index 22bfd3e..9c96882 100644
--- a/examples/tutorials/addressbook/part2/main.cpp
+++ b/examples/tutorials/addressbook/part2/main.cpp
@@ -47,8 +47,8 @@ int main(int argc, char *argv[])
{
QApplication app(argc, argv);
- AddressBook *addressBook = new AddressBook;
- addressBook->show();
+ AddressBook addressBook;
+ addressBook.show();
return app.exec();
}
diff --git a/examples/tutorials/addressbook/part3/main.cpp b/examples/tutorials/addressbook/part3/main.cpp
index b25d656..46f6f03 100644
--- a/examples/tutorials/addressbook/part3/main.cpp
+++ b/examples/tutorials/addressbook/part3/main.cpp
@@ -46,8 +46,8 @@ int main(int argc, char *argv[])
{
QApplication app(argc, argv);
- AddressBook *addressBook = new AddressBook;
- addressBook->show();
+ AddressBook addressBook;
+ addressBook.show();
return app.exec();
}
diff --git a/examples/tutorials/addressbook/part4/main.cpp b/examples/tutorials/addressbook/part4/main.cpp
index b25d656..46f6f03 100644
--- a/examples/tutorials/addressbook/part4/main.cpp
+++ b/examples/tutorials/addressbook/part4/main.cpp
@@ -46,8 +46,8 @@ int main(int argc, char *argv[])
{
QApplication app(argc, argv);
- AddressBook *addressBook = new AddressBook;
- addressBook->show();
+ AddressBook addressBook;
+ addressBook.show();
return app.exec();
}
diff --git a/examples/tutorials/addressbook/part5/main.cpp b/examples/tutorials/addressbook/part5/main.cpp
index b25d656..46f6f03 100644
--- a/examples/tutorials/addressbook/part5/main.cpp
+++ b/examples/tutorials/addressbook/part5/main.cpp
@@ -46,8 +46,8 @@ int main(int argc, char *argv[])
{
QApplication app(argc, argv);
- AddressBook *addressBook = new AddressBook;
- addressBook->show();
+ AddressBook addressBook;
+ addressBook.show();
return app.exec();
}
diff --git a/examples/tutorials/addressbook/part6/main.cpp b/examples/tutorials/addressbook/part6/main.cpp
index b25d656..46f6f03 100644
--- a/examples/tutorials/addressbook/part6/main.cpp
+++ b/examples/tutorials/addressbook/part6/main.cpp
@@ -46,8 +46,8 @@ int main(int argc, char *argv[])
{
QApplication app(argc, argv);
- AddressBook *addressBook = new AddressBook;
- addressBook->show();
+ AddressBook addressBook;
+ addressBook.show();
return app.exec();
}
diff --git a/examples/tutorials/addressbook/part7/main.cpp b/examples/tutorials/addressbook/part7/main.cpp
index b25d656..46f6f03 100644
--- a/examples/tutorials/addressbook/part7/main.cpp
+++ b/examples/tutorials/addressbook/part7/main.cpp
@@ -46,8 +46,8 @@ int main(int argc, char *argv[])
{
QApplication app(argc, argv);
- AddressBook *addressBook = new AddressBook;
- addressBook->show();
+ AddressBook addressBook;
+ addressBook.show();
return app.exec();
}
diff --git a/examples/tutorials/widgets/childwidget/childwidget.pro b/examples/tutorials/widgets/childwidget/childwidget.pro
new file mode 100644
index 0000000..37ae98e
--- /dev/null
+++ b/examples/tutorials/widgets/childwidget/childwidget.pro
@@ -0,0 +1,7 @@
+SOURCES = main.cpp
+
+# install
+target.path = $$[QT_INSTALL_EXAMPLES]/tutorials/widgets/childwidget
+sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS childwidget.pro
+sources.path = $$[QT_INSTALL_EXAMPLES]/tutorials/widgets/childwidget
+INSTALLS += target sources
diff --git a/examples/tutorials/widgets/childwidget/main.cpp b/examples/tutorials/widgets/childwidget/main.cpp
new file mode 100644
index 0000000..fd50b1d
--- /dev/null
+++ b/examples/tutorials/widgets/childwidget/main.cpp
@@ -0,0 +1,61 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain
+** additional rights. These rights are described in the Nokia Qt LGPL
+** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//! [main program]
+#include <QtGui>
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+ QWidget window;
+ window.resize(320, 240);
+ window.setWindowTitle(QApplication::translate("childwidget", "Child widget"));
+ window.show();
+
+//! [create, position and show]
+ QPushButton *button = new QPushButton(
+ QApplication::translate("childwidget", "Press me"), &window);
+ button->move(100, 100);
+ button->show();
+//! [create, position and show]
+ return app.exec();
+}
+//! [main program]
diff --git a/examples/tutorials/widgets/nestedlayouts/main.cpp b/examples/tutorials/widgets/nestedlayouts/main.cpp
new file mode 100644
index 0000000..226d0f9
--- /dev/null
+++ b/examples/tutorials/widgets/nestedlayouts/main.cpp
@@ -0,0 +1,104 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain
+** additional rights. These rights are described in the Nokia Qt LGPL
+** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//! [main program]
+//! [first part]
+#include <QtGui>
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+ QWidget window;
+
+ QLabel *queryLabel = new QLabel(
+ QApplication::translate("nestedlayouts", "Query:"));
+ QLineEdit *queryEdit = new QLineEdit();
+ QTableView *resultView = new QTableView();
+
+ QHBoxLayout *queryLayout = new QHBoxLayout();
+ queryLayout->addWidget(queryLabel);
+ queryLayout->addWidget(queryEdit);
+
+ QVBoxLayout *mainLayout = new QVBoxLayout();
+ mainLayout->addLayout(queryLayout);
+ mainLayout->addWidget(resultView);
+ window.setLayout(mainLayout);
+
+ // Set up the model and configure the view...
+//! [first part]
+
+//! [set up the model]
+ QStandardItemModel model;
+ model.setHorizontalHeaderLabels(
+ QStringList() << QApplication::translate("nestedlayouts", "Name")
+ << QApplication::translate("nestedlayouts", "Office"));
+
+ QList<QStringList> rows = QList<QStringList>()
+ << (QStringList() << "Verne Nilsen" << "123")
+ << (QStringList() << "Carlos Tang" << "77")
+ << (QStringList() << "Bronwyn Hawcroft" << "119")
+ << (QStringList() << "Alessandro Hanssen" << "32")
+ << (QStringList() << "Andrew John Bakken" << "54")
+ << (QStringList() << "Vanessa Weatherley" << "85")
+ << (QStringList() << "Rebecca Dickens" << "17")
+ << (QStringList() << "David Bradley" << "42")
+ << (QStringList() << "Knut Walters" << "25")
+ << (QStringList() << "Andrea Jones" << "34");
+
+ foreach (QStringList row, rows) {
+ QList<QStandardItem *> items;
+ foreach (QString text, row)
+ items.append(new QStandardItem(text));
+ model.appendRow(items);
+ }
+
+ resultView->setModel(&model);
+ resultView->verticalHeader()->hide();
+ resultView->horizontalHeader()->setStretchLastSection(true);
+//! [set up the model]
+//! [last part]
+ window.setWindowTitle(
+ QApplication::translate("nestedlayouts", "Nested layouts"));
+ window.show();
+ return app.exec();
+}
+//! [last part]
+//! [main program]
diff --git a/examples/tutorials/widgets/nestedlayouts/nestedlayouts.pro b/examples/tutorials/widgets/nestedlayouts/nestedlayouts.pro
new file mode 100644
index 0000000..a7f141c
--- /dev/null
+++ b/examples/tutorials/widgets/nestedlayouts/nestedlayouts.pro
@@ -0,0 +1,7 @@
+SOURCES = main.cpp
+
+# install
+target.path = $$[QT_INSTALL_EXAMPLES]/tutorials/widgets/nestedlayouts
+sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS nestedlayouts.pro
+sources.path = $$[QT_INSTALL_EXAMPLES]/tutorials/widgets/nestedlayouts
+INSTALLS += target sources
diff --git a/examples/tutorials/widgets/toplevel/main.cpp b/examples/tutorials/widgets/toplevel/main.cpp
new file mode 100644
index 0000000..f18fa6b
--- /dev/null
+++ b/examples/tutorials/widgets/toplevel/main.cpp
@@ -0,0 +1,57 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain
+** additional rights. These rights are described in the Nokia Qt LGPL
+** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//! [main program]
+#include <QtGui>
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+//! [create, resize and show]
+ QWidget window;
+ window.resize(320, 240);
+ window.show();
+//! [create, resize and show]
+ window.setWindowTitle(
+ QApplication::translate("toplevel", "Top-level widget"));
+ return app.exec();
+}
+//! [main program]
diff --git a/examples/tutorials/widgets/toplevel/toplevel.pro b/examples/tutorials/widgets/toplevel/toplevel.pro
new file mode 100644
index 0000000..58d59c5
--- /dev/null
+++ b/examples/tutorials/widgets/toplevel/toplevel.pro
@@ -0,0 +1,7 @@
+SOURCES = main.cpp
+
+# install
+target.path = $$[QT_INSTALL_EXAMPLES]/tutorials/widgets/toplevel
+sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS toplevel.pro
+sources.path = $$[QT_INSTALL_EXAMPLES]/tutorials/widgets/toplevel
+INSTALLS += target sources
diff --git a/examples/tutorials/widgets/widgets.pro b/examples/tutorials/widgets/widgets.pro
new file mode 100644
index 0000000..7a870e7
--- /dev/null
+++ b/examples/tutorials/widgets/widgets.pro
@@ -0,0 +1,8 @@
+TEMPLATE = subdirs
+SUBDIRS = toplevel childwidget windowlayout nestedlayouts
+
+# install
+target.path = $$[QT_INSTALL_EXAMPLES]/tutorials/widgets
+sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS widgets.pro README
+sources.path = $$[QT_INSTALL_EXAMPLES]/tutorials/widgets
+INSTALLS += target sources
diff --git a/examples/tutorials/widgets/windowlayout/main.cpp b/examples/tutorials/widgets/windowlayout/main.cpp
new file mode 100644
index 0000000..c30d669
--- /dev/null
+++ b/examples/tutorials/widgets/windowlayout/main.cpp
@@ -0,0 +1,63 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain
+** additional rights. These rights are described in the Nokia Qt LGPL
+** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//! [main program]
+#include <QtGui>
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+ QWidget window;
+//! [create, lay out widgets and show]
+ QLabel *label = new QLabel(QApplication::translate("windowlayout", "Name:"));
+ QLineEdit *lineEdit = new QLineEdit();
+
+ QHBoxLayout *layout = new QHBoxLayout();
+ layout->addWidget(label);
+ layout->addWidget(lineEdit);
+ window.setLayout(layout);
+//! [create, lay out widgets and show]
+ window.setWindowTitle(
+ QApplication::translate("windowlayout", "Window layout"));
+ window.show();
+ return app.exec();
+}
+//! [main program]
diff --git a/examples/tutorials/widgets/windowlayout/windowlayout.pro b/examples/tutorials/widgets/windowlayout/windowlayout.pro
new file mode 100644
index 0000000..408f6ef
--- /dev/null
+++ b/examples/tutorials/widgets/windowlayout/windowlayout.pro
@@ -0,0 +1,7 @@
+SOURCES = main.cpp
+
+# install
+target.path = $$[QT_INSTALL_EXAMPLES]/tutorials/widgets/windowlayout
+sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS windowlayout.pro
+sources.path = $$[QT_INSTALL_EXAMPLES]/tutorials/widgets/windowlayout
+INSTALLS += target sources
diff --git a/examples/webkit/fancybrowser/mainwindow.cpp b/examples/webkit/fancybrowser/mainwindow.cpp
index bf61f9c..e24f6cf 100644
--- a/examples/webkit/fancybrowser/mainwindow.cpp
+++ b/examples/webkit/fancybrowser/mainwindow.cpp
@@ -43,6 +43,8 @@
#include <QtWebKit>
#include "mainwindow.h"
+//! [1]
+
MainWindow::MainWindow()
{
progress = 0;
@@ -52,7 +54,9 @@ MainWindow::MainWindow()
file.open(QIODevice::ReadOnly);
jQuery = file.readAll();
file.close();
+//! [1]
+//! [2]
view = new QWebView(this);
view->load(QUrl("http://www.google.com/ncr"));
connect(view, SIGNAL(loadFinished(bool)), SLOT(adjustLocation()));
@@ -70,7 +74,9 @@ MainWindow::MainWindow()
toolBar->addAction(view->pageAction(QWebPage::Reload));
toolBar->addAction(view->pageAction(QWebPage::Stop));
toolBar->addWidget(locationEdit);
+//! [2]
+//! [3]
QMenu *effectMenu = menuBar()->addMenu(tr("&Effect"));
effectMenu->addAction("Highlight all links", this, SLOT(highlightAllLinks()));
@@ -89,7 +95,9 @@ MainWindow::MainWindow()
setCentralWidget(view);
}
+//! [3]
+//! [4]
void MainWindow::adjustLocation()
{
locationEdit->setText(view->url().toString());
@@ -98,11 +106,12 @@ void MainWindow::adjustLocation()
void MainWindow::changeLocation()
{
QUrl url = QUrl(locationEdit->text());
- locationEdit->setText(url.toString());
view->load(url);
view->setFocus();
}
+//! [4]
+//! [5]
void MainWindow::adjustTitle()
{
if (progress <= 0 || progress >= 100)
@@ -116,20 +125,26 @@ void MainWindow::setProgress(int p)
progress = p;
adjustTitle();
}
+//! [5]
+//! [6]
void MainWindow::finishLoading(bool)
{
progress = 100;
adjustTitle();
view->page()->mainFrame()->evaluateJavaScript(jQuery);
}
+//! [6]
+//! [7]
void MainWindow::highlightAllLinks()
{
QString code = "$('a').each( function () { $(this).css('background-color', 'yellow') } )";
view->page()->mainFrame()->evaluateJavaScript(code);
}
+//! [7]
+//! [8]
void MainWindow::rotateImages(bool toggle)
{
QString code = "$('img').each( function () { $(this).css('-webkit-transition', '-webkit-transform 2s') } )";
@@ -140,7 +155,9 @@ void MainWindow::rotateImages(bool toggle)
code = "$('img').each( function () { $(this).css('-webkit-transform', 'rotate(0deg)') } )";
view->page()->mainFrame()->evaluateJavaScript(code);
}
+//! [8]
+//! [9]
void MainWindow::removeGifImages()
{
QString code = "$('[src*=gif]').remove()";
@@ -164,4 +181,5 @@ void MainWindow::removeEmbeddedElements()
QString code = "$('embed').remove()";
view->page()->mainFrame()->evaluateJavaScript(code);
}
+//! [9]
diff --git a/examples/webkit/fancybrowser/mainwindow.h b/examples/webkit/fancybrowser/mainwindow.h
index 9362ca7..2e1068c 100644
--- a/examples/webkit/fancybrowser/mainwindow.h
+++ b/examples/webkit/fancybrowser/mainwindow.h
@@ -39,13 +39,14 @@
**
****************************************************************************/
-#include <QMainWindow>
+#include <QtGui>
QT_BEGIN_NAMESPACE
class QWebView;
class QLineEdit;
QT_END_NAMESPACE
+//! [1]
class MainWindow : public QMainWindow
{
Q_OBJECT
@@ -73,4 +74,5 @@ private:
QWebView *view;
QLineEdit *locationEdit;
int progress;
+//! [1]
};
diff --git a/examples/webkit/formextractor/mainwindow.cpp b/examples/webkit/formextractor/mainwindow.cpp
index 222d9b2..ec4d043 100644
--- a/examples/webkit/formextractor/mainwindow.cpp
+++ b/examples/webkit/formextractor/mainwindow.cpp
@@ -54,7 +54,7 @@ void MainWindow::createActions()
{
exitAct = new QAction(tr("E&xit"), this);
exitAct->setStatusTip(tr("Exit the application"));
- exitAct->setShortcut(tr("Ctrl+Q"));
+ exitAct->setShortcuts(QKeySequence::Quit);
connect(exitAct, SIGNAL(triggered()), this, SLOT(close()));
aboutAct = new QAction(tr("&About"), this);
diff --git a/examples/webkit/previewer/mainwindow.cpp b/examples/webkit/previewer/mainwindow.cpp
index abe7941..1e20ed3 100644
--- a/examples/webkit/previewer/mainwindow.cpp
+++ b/examples/webkit/previewer/mainwindow.cpp
@@ -61,7 +61,7 @@ MainWindow::MainWindow()
void MainWindow::createActions()
{
openAct = new QAction(tr("&Open..."), this);
- openAct->setShortcut(tr("Ctrl+O"));
+ openAct->setShortcuts(QKeySequence::Open);
openAct->setStatusTip(tr("Open an existing HTML file"));
connect(openAct, SIGNAL(triggered()), this, SLOT(open()));
@@ -72,13 +72,13 @@ void MainWindow::createActions()
//! [1]
saveAct = new QAction(tr("&Save"), this);
- saveAct->setShortcut(tr("Ctrl+S"));
+ saveAct->setShortcuts(QKeySequence::Save);
saveAct->setStatusTip(tr("Save the HTML file to disk"));
connect(saveAct, SIGNAL(triggered()), this, SLOT(save()));
exitAct = new QAction(tr("E&xit"), this);
exitAct->setStatusTip(tr("Exit the application"));
- exitAct->setShortcut(tr("Ctrl+Q"));
+ exitAct->setShortcuts(QKeySequence::Quit);
connect(exitAct, SIGNAL(triggered()), this, SLOT(close()));
aboutAct = new QAction(tr("&About"), this);
diff --git a/examples/widgets/codeeditor/codeeditor.cpp b/examples/widgets/codeeditor/codeeditor.cpp
index b855c7a..615f39f 100644
--- a/examples/widgets/codeeditor/codeeditor.cpp
+++ b/examples/widgets/codeeditor/codeeditor.cpp
@@ -41,7 +41,7 @@
#include <QtGui>
-#include <codeeditor.h>
+#include "codeeditor.h"
//![constructor]
diff --git a/examples/widgets/icons/mainwindow.cpp b/examples/widgets/icons/mainwindow.cpp
index 00ce8b0..db42710 100644
--- a/examples/widgets/icons/mainwindow.cpp
+++ b/examples/widgets/icons/mainwindow.cpp
@@ -369,7 +369,7 @@ void MainWindow::createActions()
this, SLOT(removeAllImages()));
exitAct = new QAction(tr("&Quit"), this);
- exitAct->setShortcut(tr("Ctrl+Q"));
+ exitAct->setShortcuts(QKeySequence::Quit);
connect(exitAct, SIGNAL(triggered()), this, SLOT(close()));
styleActionGroup = new QActionGroup(this);
diff --git a/examples/widgets/scribble/mainwindow.cpp b/examples/widgets/scribble/mainwindow.cpp
index ad1a837..c4b05fe 100644
--- a/examples/widgets/scribble/mainwindow.cpp
+++ b/examples/widgets/scribble/mainwindow.cpp
@@ -141,7 +141,7 @@ void MainWindow::createActions()
//! [13] //! [14]
{
openAct = new QAction(tr("&Open..."), this);
- openAct->setShortcut(tr("Ctrl+O"));
+ openAct->setShortcuts(QKeySequence::Open);
connect(openAct, SIGNAL(triggered()), this, SLOT(open()));
foreach (QByteArray format, QImageWriter::supportedImageFormats()) {
@@ -157,7 +157,7 @@ void MainWindow::createActions()
connect(printAct, SIGNAL(triggered()), scribbleArea, SLOT(print()));
exitAct = new QAction(tr("E&xit"), this);
- exitAct->setShortcut(tr("Ctrl+Q"));
+ exitAct->setShortcuts(QKeySequence::Quit);
connect(exitAct, SIGNAL(triggered()), this, SLOT(close()));
penColorAct = new QAction(tr("&Pen Color..."), this);
diff --git a/examples/widgets/tablet/mainwindow.cpp b/examples/widgets/tablet/mainwindow.cpp
index 56a10cd..10490bf 100644
--- a/examples/widgets/tablet/mainwindow.cpp
+++ b/examples/widgets/tablet/mainwindow.cpp
@@ -212,17 +212,17 @@ void MainWindow::createActions()
this, SLOT(lineWidthActionTriggered(QAction *)));
exitAction = new QAction(tr("E&xit"), this);
- exitAction->setShortcut(tr("Ctrl+X"));
+ exitAction->setShortcuts(QKeySequence::Quit);
connect(exitAction, SIGNAL(triggered()),
this, SLOT(close()));
loadAction = new QAction(tr("&Open..."), this);
- loadAction->setShortcut(tr("Ctrl+O"));
+ loadAction->setShortcuts(QKeySequence::Open);
connect(loadAction, SIGNAL(triggered()),
this, SLOT(loadAct()));
saveAction = new QAction(tr("&Save As..."), this);
- saveAction->setShortcut(tr("Ctrl+S"));
+ saveAction->setShortcuts(QKeySequence::SaveAs);
connect(saveAction, SIGNAL(triggered()),
this, SLOT(saveAct()));
diff --git a/examples/xml/dombookmarks/mainwindow.cpp b/examples/xml/dombookmarks/mainwindow.cpp
index 6b0c101..7efe6ff 100644
--- a/examples/xml/dombookmarks/mainwindow.cpp
+++ b/examples/xml/dombookmarks/mainwindow.cpp
@@ -113,15 +113,15 @@ void MainWindow::about()
void MainWindow::createActions()
{
openAct = new QAction(tr("&Open..."), this);
- openAct->setShortcut(tr("Ctrl+O"));
+ openAct->setShortcuts(QKeySequence::Open);
connect(openAct, SIGNAL(triggered()), this, SLOT(open()));
saveAsAct = new QAction(tr("&Save As..."), this);
- saveAsAct->setShortcut(tr("Ctrl+S"));
+ saveAsAct->setShortcuts(QKeySequence::SaveAs);
connect(saveAsAct, SIGNAL(triggered()), this, SLOT(saveAs()));
exitAct = new QAction(tr("E&xit"), this);
- exitAct->setShortcut(tr("Ctrl+Q"));
+ exitAct->setShortcuts(QKeySequence::Quit);
connect(exitAct, SIGNAL(triggered()), this, SLOT(close()));
aboutAct = new QAction(tr("&About"), this);
diff --git a/examples/xml/saxbookmarks/mainwindow.cpp b/examples/xml/saxbookmarks/mainwindow.cpp
index 2cba559..9247eb7 100644
--- a/examples/xml/saxbookmarks/mainwindow.cpp
+++ b/examples/xml/saxbookmarks/mainwindow.cpp
@@ -128,15 +128,15 @@ void MainWindow::about()
void MainWindow::createActions()
{
openAct = new QAction(tr("&Open..."), this);
- openAct->setShortcut(tr("Ctrl+O"));
+ openAct->setShortcuts(QKeySequence::Open);
connect(openAct, SIGNAL(triggered()), this, SLOT(open()));
saveAsAct = new QAction(tr("&Save As..."), this);
- saveAsAct->setShortcut(tr("Ctrl+S"));
+ saveAsAct->setShortcuts(QKeySequence::SaveAs);
connect(saveAsAct, SIGNAL(triggered()), this, SLOT(saveAs()));
exitAct = new QAction(tr("E&xit"), this);
- exitAct->setShortcut(tr("Ctrl+Q"));
+ exitAct->setShortcuts(QKeySequence::Quit);
connect(exitAct, SIGNAL(triggered()), this, SLOT(close()));
aboutAct = new QAction(tr("&About"), this);
diff --git a/examples/xml/streambookmarks/mainwindow.cpp b/examples/xml/streambookmarks/mainwindow.cpp
index 2136b4b..c6f991b 100644
--- a/examples/xml/streambookmarks/mainwindow.cpp
+++ b/examples/xml/streambookmarks/mainwindow.cpp
@@ -141,15 +141,15 @@ void MainWindow::about()
void MainWindow::createActions()
{
openAct = new QAction(tr("&Open..."), this);
- openAct->setShortcut(tr("Ctrl+O"));
+ openAct->setShortcuts(QKeySequence::Open);
connect(openAct, SIGNAL(triggered()), this, SLOT(open()));
saveAsAct = new QAction(tr("&Save As..."), this);
- saveAsAct->setShortcut(tr("Ctrl+S"));
+ saveAsAct->setShortcuts(QKeySequence::SaveAs);
connect(saveAsAct, SIGNAL(triggered()), this, SLOT(saveAs()));
exitAct = new QAction(tr("E&xit"), this);
- exitAct->setShortcut(tr("Ctrl+Q"));
+ exitAct->setShortcuts(QKeySequence::Quit);
connect(exitAct, SIGNAL(triggered()), this, SLOT(close()));
aboutAct = new QAction(tr("&About"), this);
diff --git a/examples/xmlpatterns/trafficinfo/main.cpp b/examples/xmlpatterns/trafficinfo/main.cpp
index 97b2bf7..544260d 100644
--- a/examples/xmlpatterns/trafficinfo/main.cpp
+++ b/examples/xmlpatterns/trafficinfo/main.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
** Contact: Qt Software Information (qt-info@nokia.com)
**
** This file is part of the examples of the Qt Toolkit.
diff --git a/examples/xmlpatterns/trafficinfo/mainwindow.cpp b/examples/xmlpatterns/trafficinfo/mainwindow.cpp
index 1f754d5..aeb7224 100644
--- a/examples/xmlpatterns/trafficinfo/mainwindow.cpp
+++ b/examples/xmlpatterns/trafficinfo/mainwindow.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
** Contact: Qt Software Information (qt-info@nokia.com)
**
** This file is part of the examples of the Qt Toolkit.
@@ -55,7 +55,7 @@ MainWindow::MainWindow()
: QWidget(0, Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint)
{
QAction *quitAction = new QAction(tr("E&xit"), this);
- quitAction->setShortcut(tr("Ctrl+Q"));
+ quitAction->setShortcuts(QKeySequence::Quit);
connect(quitAction, SIGNAL(triggered()), qApp, SLOT(quit()));
QAction *configAction = new QAction(tr("&Select station..."), this);
diff --git a/examples/xmlpatterns/trafficinfo/mainwindow.h b/examples/xmlpatterns/trafficinfo/mainwindow.h
index d48109d..5362bcd 100644
--- a/examples/xmlpatterns/trafficinfo/mainwindow.h
+++ b/examples/xmlpatterns/trafficinfo/mainwindow.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
** Contact: Qt Software Information (qt-info@nokia.com)
**
** This file is part of the examples of the Qt Toolkit.
diff --git a/examples/xmlpatterns/trafficinfo/stationdialog.cpp b/examples/xmlpatterns/trafficinfo/stationdialog.cpp
index 9876bdb..54ed904 100644
--- a/examples/xmlpatterns/trafficinfo/stationdialog.cpp
+++ b/examples/xmlpatterns/trafficinfo/stationdialog.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
** Contact: Qt Software Information (qt-info@nokia.com)
**
** This file is part of the examples of the Qt Toolkit.
diff --git a/examples/xmlpatterns/trafficinfo/stationdialog.h b/examples/xmlpatterns/trafficinfo/stationdialog.h
index 5ac1635..0e87f61 100644
--- a/examples/xmlpatterns/trafficinfo/stationdialog.h
+++ b/examples/xmlpatterns/trafficinfo/stationdialog.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
** Contact: Qt Software Information (qt-info@nokia.com)
**
** This file is part of the examples of the Qt Toolkit.
diff --git a/examples/xmlpatterns/trafficinfo/stationquery.cpp b/examples/xmlpatterns/trafficinfo/stationquery.cpp
index ab42ad9..3db0fdb 100644
--- a/examples/xmlpatterns/trafficinfo/stationquery.cpp
+++ b/examples/xmlpatterns/trafficinfo/stationquery.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
** Contact: Qt Software Information (qt-info@nokia.com)
**
** This file is part of the examples of the Qt Toolkit.
diff --git a/examples/xmlpatterns/trafficinfo/stationquery.h b/examples/xmlpatterns/trafficinfo/stationquery.h
index 5cbf28a..d1e4d2f 100644
--- a/examples/xmlpatterns/trafficinfo/stationquery.h
+++ b/examples/xmlpatterns/trafficinfo/stationquery.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
** Contact: Qt Software Information (qt-info@nokia.com)
**
** This file is part of the examples of the Qt Toolkit.
diff --git a/examples/xmlpatterns/trafficinfo/timequery.cpp b/examples/xmlpatterns/trafficinfo/timequery.cpp
index bd63560..d6bf695 100644
--- a/examples/xmlpatterns/trafficinfo/timequery.cpp
+++ b/examples/xmlpatterns/trafficinfo/timequery.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
** Contact: Qt Software Information (qt-info@nokia.com)
**
** This file is part of the examples of the Qt Toolkit.
diff --git a/examples/xmlpatterns/trafficinfo/timequery.h b/examples/xmlpatterns/trafficinfo/timequery.h
index f88e62c..2435c71 100644
--- a/examples/xmlpatterns/trafficinfo/timequery.h
+++ b/examples/xmlpatterns/trafficinfo/timequery.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
** Contact: Qt Software Information (qt-info@nokia.com)
**
** This file is part of the examples of the Qt Toolkit.