summaryrefslogtreecommitdiffstats
path: root/doc/src/snippets
diff options
context:
space:
mode:
Diffstat (limited to 'doc/src/snippets')
-rw-r--r--doc/src/snippets/colors/colors.pro2
-rw-r--r--doc/src/snippets/colors/main.cpp52
-rw-r--r--doc/src/snippets/colors/window.cpp131
-rw-r--r--doc/src/snippets/colors/window.h (renamed from doc/src/snippets/code/doc_src_examples_ahigl.qdoc)16
-rw-r--r--doc/src/snippets/gestures/qgesture.cpp32
-rw-r--r--doc/src/snippets/shareddirmodel/main.cpp5
-rw-r--r--doc/src/snippets/simplemodel-use/main.cpp2
7 files changed, 215 insertions, 25 deletions
diff --git a/doc/src/snippets/colors/colors.pro b/doc/src/snippets/colors/colors.pro
new file mode 100644
index 0000000..b2cc87d
--- /dev/null
+++ b/doc/src/snippets/colors/colors.pro
@@ -0,0 +1,2 @@
+HEADERS = window.h
+SOURCES = main.cpp window.cpp
diff --git a/doc/src/snippets/colors/main.cpp b/doc/src/snippets/colors/main.cpp
new file mode 100644
index 0000000..4e09036
--- /dev/null
+++ b/doc/src/snippets/colors/main.cpp
@@ -0,0 +1,52 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (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 Technology Preview License Agreement accompanying
+** this package.
+**
+** 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.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtGui>
+#include "window.h"
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+ Window window;
+ window.setFixedSize(640, 215);
+ window.show();
+ return app.exec();
+}
diff --git a/doc/src/snippets/colors/window.cpp b/doc/src/snippets/colors/window.cpp
new file mode 100644
index 0000000..0cec5f5
--- /dev/null
+++ b/doc/src/snippets/colors/window.cpp
@@ -0,0 +1,131 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (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 Technology Preview License Agreement accompanying
+** this package.
+**
+** 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.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtGui>
+#include "window.h"
+
+Window::Window(QWidget *parent)
+ : QWidget(parent)
+{
+ QFont font;
+ font.setPixelSize(12);
+ setFont(font);
+}
+
+void Window::closeEvent(QCloseEvent *event)
+{
+ QPixmap pixmap(size());
+ render(&pixmap);
+ pixmap.save("qt-colors.png");
+
+ event->accept();
+}
+
+void Window::paintEvent(QPaintEvent *)
+{
+ QPainter painter;
+ painter.begin(this);
+
+ int h = 216 / 5;
+ QRect r = QRect(0, 0, 160, h);
+ painter.fillRect(r, Qt::white);
+ painter.setPen(Qt::black);
+ painter.drawText(r, Qt::AlignCenter, QLatin1String("white"));
+ r = QRect(0, h, 160, h);
+ painter.fillRect(r, Qt::red);
+ painter.drawText(r, Qt::AlignCenter, QLatin1String("red"));
+ r = QRect(0, h*2, 160, h);
+ painter.fillRect(r, Qt::green);
+ painter.drawText(r, Qt::AlignCenter, QLatin1String("green"));
+ r = QRect(0, h*3, 160, h);
+ painter.fillRect(r, Qt::blue);
+ painter.setPen(Qt::white);
+ painter.drawText(r, Qt::AlignCenter, QLatin1String("blue"));
+
+ r = QRect(160, 0, 160, h);
+ painter.fillRect(r, Qt::black);
+ painter.drawText(r, Qt::AlignCenter, QLatin1String("black"));
+ r = QRect(160, h, 160, h);
+ painter.fillRect(r, Qt::darkRed);
+ painter.drawText(r, Qt::AlignCenter, QLatin1String("darkRed"));
+ r = QRect(160, h*2, 160, h);
+ painter.fillRect(r, Qt::darkGreen);
+ painter.drawText(r, Qt::AlignCenter, QLatin1String("darkGreen"));
+ r = QRect(160, h*3, 160, h);
+ painter.fillRect(r, Qt::darkBlue);
+ painter.drawText(r, Qt::AlignCenter, QLatin1String("darkBlue"));
+
+ r = QRect(320, 0, 160, h);
+ painter.fillRect(r, Qt::cyan);
+ painter.setPen(Qt::black);
+ painter.drawText(r, Qt::AlignCenter, QLatin1String("cyan"));
+ r = QRect(320, h, 160, h);
+ painter.fillRect(r, Qt::magenta);
+ painter.drawText(r, Qt::AlignCenter, QLatin1String("magenta"));
+ r = QRect(320, h*2, 160, h);
+ painter.fillRect(r, Qt::yellow);
+ painter.drawText(r, Qt::AlignCenter, QLatin1String("yellow"));
+ r = QRect(320, h*3, 160, h);
+ painter.fillRect(r, Qt::gray);
+ painter.setPen(Qt::white);
+ painter.drawText(r, Qt::AlignCenter, QLatin1String("gray"));
+
+ r = QRect(480, 0, 160, h);
+ painter.fillRect(r, Qt::darkCyan);
+ painter.drawText(r, Qt::AlignCenter, QLatin1String("darkCyan"));
+ r = QRect(480, h, 160, h);
+ painter.fillRect(r, Qt::darkMagenta);
+ painter.drawText(r, Qt::AlignCenter, QLatin1String("darkMagenta"));
+ r = QRect(480, h*2, 160, h);
+ painter.fillRect(r, Qt::darkYellow);
+ painter.drawText(r, Qt::AlignCenter, QLatin1String("darkYellow"));
+ r = QRect(480, h*3, 160, h);
+ painter.fillRect(r, Qt::darkGray);
+ painter.drawText(r, Qt::AlignCenter, QLatin1String("darkGray"));
+
+ r = QRect(0, h*4, 640, h);
+ painter.fillRect(r, Qt::lightGray);
+ painter.setPen(Qt::black);
+ painter.drawText(r, Qt::AlignCenter, QLatin1String("lightGray"));
+
+ painter.end();
+}
+
diff --git a/doc/src/snippets/code/doc_src_examples_ahigl.qdoc b/doc/src/snippets/colors/window.h
index ccdce8b..3b08b90 100644
--- a/doc/src/snippets/code/doc_src_examples_ahigl.qdoc
+++ b/doc/src/snippets/colors/window.h
@@ -39,11 +39,15 @@
**
****************************************************************************/
-//! [0]
-myApplication -qws -display ahigl
-//! [0]
+#include <QWidget>
+class Window : public QWidget
+{
+public:
+ Window(QWidget *parent = 0);
+
+protected:
+ void closeEvent(QCloseEvent *event);
+ void paintEvent(QPaintEvent *event);
+};
-//! [1]
-myApplication -qws -display ahigl
-//! [1]
diff --git a/doc/src/snippets/gestures/qgesture.cpp b/doc/src/snippets/gestures/qgesture.cpp
index 65f8b24..77f5cc2 100644
--- a/doc/src/snippets/gestures/qgesture.cpp
+++ b/doc/src/snippets/gestures/qgesture.cpp
@@ -64,7 +64,7 @@ private:
QGesture *gesture;
};
-/*!
+/*
\class QGesture
\since 4.6
@@ -100,7 +100,7 @@ private:
\sa QPanGesture
*/
-/*! \fn bool QGesture::filterEvent(QEvent *event)
+/* \fn bool QGesture::filterEvent(QEvent *event)
Parses input \a event and emits a signal when detects a gesture.
@@ -111,7 +111,7 @@ private:
This is a pure virtual function that needs to be implemented in subclasses.
*/
-/*! \fn void QGesture::started()
+/* \fn void QGesture::started()
The signal is emitted when the gesture is started. Extended information
about the gesture is contained in the signal sender object.
@@ -119,19 +119,19 @@ private:
In addition to started(), a triggered() signal should also be emitted.
*/
-/*! \fn void QGesture::triggered()
+/* \fn void QGesture::triggered()
The signal is emitted when the gesture is detected. Extended information
about the gesture is contained in the signal sender object.
*/
-/*! \fn void QGesture::finished()
+/* \fn void QGesture::finished()
The signal is emitted when the gesture is finished. Extended information
about the gesture is contained in the signal sender object.
*/
-/*! \fn void QGesture::cancelled()
+/* \fn void QGesture::cancelled()
The signal is emitted when the gesture is cancelled, for example the reset()
function is called while the gesture was in the process of emitting a
@@ -140,7 +140,7 @@ private:
*/
-/*!
+/*
Creates a new gesture handler object and marks it as a child of \a parent.
The \a parent object is also the default event source for the gesture,
@@ -156,7 +156,7 @@ QGesture::QGesture(QObject *parent)
parent->installEventFilter(this);
}
-/*! \internal
+/* \internal
*/
QGesture::QGesture(QGesturePrivate &dd, QObject *parent)
: QObject(dd, parent)
@@ -165,14 +165,14 @@ QGesture::QGesture(QGesturePrivate &dd, QObject *parent)
parent->installEventFilter(this);
}
-/*!
+/*
Destroys the gesture object.
*/
QGesture::~QGesture()
{
}
-/*! \internal
+/* \internal
*/
bool QGesture::eventFilter(QObject *receiver, QEvent *event)
{
@@ -182,13 +182,13 @@ bool QGesture::eventFilter(QObject *receiver, QEvent *event)
return filterEvent(event);
}
-/*!
+/*
\property QGesture::state
\brief The current state of the gesture.
*/
-/*!
+/*
Returns the gesture recognition state.
*/
Qt::GestureState QGesture::state() const
@@ -196,7 +196,7 @@ Qt::GestureState QGesture::state() const
return d_func()->state;
}
-/*!
+/*
Sets this gesture's recognition state to \a state and emits appropriate
signals.
@@ -237,7 +237,7 @@ void QGesture::updateState(Qt::GestureState state)
}
}
-/*!
+/*
Sets the \a graphicsItem the gesture is filtering events for.
The gesture will install an event filter to the \a graphicsItem and
@@ -257,7 +257,7 @@ void QGesture::setGraphicsItem(QGraphicsItem *graphicsItem)
graphicsItem->installSceneEventFilter(d->eventFilterProxyGraphicsItem);
}
-/*!
+/*
Returns the graphics item the gesture is filtering events for.
\sa setGraphicsItem()
@@ -267,7 +267,7 @@ QGraphicsItem* QGesture::graphicsItem() const
return d_func()->graphicsItem;
}
-/*! \fn void QGesture::reset()
+/* \fn void QGesture::reset()
Resets the internal state of the gesture. This function might be called by
the filterEvent() implementation in a derived class, or by the user to
diff --git a/doc/src/snippets/shareddirmodel/main.cpp b/doc/src/snippets/shareddirmodel/main.cpp
index 82034b5..3cb63c9 100644
--- a/doc/src/snippets/shareddirmodel/main.cpp
+++ b/doc/src/snippets/shareddirmodel/main.cpp
@@ -55,7 +55,8 @@ int main(int argc, char *argv[])
QSplitter *splitter = new QSplitter;
//! [2] //! [3]
- QDirModel *model = new QDirModel;
+ QFileSystemModel *model = new QFileSystemModel;
+ model->setRootPath(QDir::currentPath());
//! [0] //! [2] //! [4] //! [5]
QTreeView *tree = new QTreeView(splitter);
//! [3] //! [6]
@@ -74,7 +75,7 @@ int main(int argc, char *argv[])
list->setSelectionModel(selection);
//! [8]
- splitter->setWindowTitle("Two views onto the same directory model");
+ splitter->setWindowTitle("Two views onto the same file system model");
splitter->show();
return app.exec();
}
diff --git a/doc/src/snippets/simplemodel-use/main.cpp b/doc/src/snippets/simplemodel-use/main.cpp
index a3bb0e7..d7fc755 100644
--- a/doc/src/snippets/simplemodel-use/main.cpp
+++ b/doc/src/snippets/simplemodel-use/main.cpp
@@ -69,7 +69,7 @@ int main(int argc, char *argv[])
layout->addWidget(title);
//! [0]
- QDirModel *model = new QDirModel;
+ QFileSystemModel *model = new QFileSystemModel;
QModelIndex parentIndex = model->index(QDir::currentPath());
int numRows = model->rowCount(parentIndex);
//! [0]