summaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
authorFrederik Gladhorn <frederik.gladhorn@digia.com>2014-10-09 17:56:51 +0200
committerFrederik Gladhorn <frederik.gladhorn@digia.com>2014-10-09 17:56:52 +0200
commit881ceeff428c377d02ae3881beccdbb028385075 (patch)
tree65bd4335d7f67b81b04e33f2cbb17a41cf966dd8 /examples
parentb3d2c867ed14cd6337d5e32b8750f198b5b7d331 (diff)
parent106487387d493dab934e19b33bfed55b8df62d67 (diff)
Merge remote-tracking branch 'origin/5.4' into dev
Diffstat (limited to 'examples')
-rw-r--r--examples/gui/doc/src/openglwindow.qdoc4
-rw-r--r--examples/json/savegame/doc/src/savegame.qdoc2
-rw-r--r--examples/opengl/doc/src/cube.qdoc6
-rw-r--r--examples/opengl/qopenglwidget/glwidget.cpp5
-rw-r--r--examples/opengl/qopenglwidget/mainwindow.cpp25
-rw-r--r--examples/opengl/qopenglwidget/mainwindow.h5
-rw-r--r--examples/widgets/doc/src/echoplugin.qdoc2
-rw-r--r--examples/widgets/doc/src/styleplugin.qdoc2
-rw-r--r--examples/widgets/doc/src/tooltips.qdoc2
-rw-r--r--examples/widgets/widgets/mousebuttons/mousebuttons.pro2
10 files changed, 44 insertions, 11 deletions
diff --git a/examples/gui/doc/src/openglwindow.qdoc b/examples/gui/doc/src/openglwindow.qdoc
index 614f5060c4..524ed908e8 100644
--- a/examples/gui/doc/src/openglwindow.qdoc
+++ b/examples/gui/doc/src/openglwindow.qdoc
@@ -34,7 +34,7 @@
\image openglwindow-example.png Screenshot of the OpenGLWindow example
- \section1 OpenGLWindow super class
+ \section1 OpenGLWindow Super Class
Our OpenGLWindow class acts as an API which is then subclassed to do the
actual rendering. It has functions to make a request for render() to be
@@ -118,7 +118,7 @@
\snippet openglwindow/openglwindow.cpp 5
- \section1 Example OpenGL rendering sub class
+ \section1 Example OpenGL Rendering Sub Class
Here we sub class OpenGLWindow to show how to do OpenGL to render a
rotating triangle. By indirectly sub classing QOpenGLFunctions we gain
diff --git a/examples/json/savegame/doc/src/savegame.qdoc b/examples/json/savegame/doc/src/savegame.qdoc
index 586c100399..872f2faf42 100644
--- a/examples/json/savegame/doc/src/savegame.qdoc
+++ b/examples/json/savegame/doc/src/savegame.qdoc
@@ -43,7 +43,7 @@
In this example, we'll demonstrate how to save and load a simple game to
and from JSON and binary formats.
- \section1 The Character class
+ \section1 The Character Class
The Character class represents a non-player character (NPC) in our game, and
stores the player's name, level, and class type.
diff --git a/examples/opengl/doc/src/cube.qdoc b/examples/opengl/doc/src/cube.qdoc
index ed1390db1a..23c15f9c43 100644
--- a/examples/opengl/doc/src/cube.qdoc
+++ b/examples/opengl/doc/src/cube.qdoc
@@ -90,7 +90,7 @@
\snippet cube/mainwidget.cpp 2
- \section1 Loading textures from Qt Resource files
+ \section1 Loading Textures from Qt Resource Files
\c QGLWidget interface implements methods for loading textures from QImage to GL
texture memory. We still need to use OpenGL provided functions for specifying
@@ -133,14 +133,14 @@
\snippet cube/geometryengine.cpp 2
- \section1 Perspective projection
+ \section1 Perspective Projection
Using \c QMatrix4x4 helper methods it's really easy to calculate perpective
projection matrix. This matrix is used to project vertices to screen space.
\snippet cube/mainwidget.cpp 5
- \section1 Orientation of the 3D object
+ \section1 Orientation of the 3D Object
Quaternions are handy way to represent orientation of the 3D object. Quaternions
involve quite complex mathematics but fortunately all the necessary mathematics
diff --git a/examples/opengl/qopenglwidget/glwidget.cpp b/examples/opengl/qopenglwidget/glwidget.cpp
index de581f8d47..d39e1992a7 100644
--- a/examples/opengl/qopenglwidget/glwidget.cpp
+++ b/examples/opengl/qopenglwidget/glwidget.cpp
@@ -394,6 +394,11 @@ void GLWidget::paintGL()
}
m_fAngle += 1.0f;
++m_frames;
+
+ // When requested, follow the ideal way to animate: Rely on
+ // blocking swap and just schedule updates continuously.
+ if (!m_mainWindow->timerEnabled())
+ update();
}
void GLWidget::createBubbles(int number)
diff --git a/examples/opengl/qopenglwidget/mainwindow.cpp b/examples/opengl/qopenglwidget/mainwindow.cpp
index 7645c75d8c..a3c8d5edcf 100644
--- a/examples/opengl/qopenglwidget/mainwindow.cpp
+++ b/examples/opengl/qopenglwidget/mainwindow.cpp
@@ -54,6 +54,7 @@ MainWindow::MainWindow()
: m_nextX(1), m_nextY(1)
{
GLWidget *glwidget = new GLWidget(this, true, qRgb(20, 20, 50));
+ m_glWidgets << glwidget;
QLabel *label = new QLabel(this);
m_timer = new QTimer(this);
QSlider *slider = new QSlider(this);
@@ -67,12 +68,19 @@ MainWindow::MainWindow()
"Note that on most systems the swap will block to wait for vsync\n"
"and therefore an interval < 16 ms will likely lead to a 60 FPS update rate.");
QGroupBox *updateGroupBox = new QGroupBox(this);
+ QCheckBox *timerBased = new QCheckBox("Use timer", this);
+ timerBased->setChecked(true);
+ timerBased->setToolTip("Toggles using a timer to trigger update().\n"
+ "When not set, each paintGL() schedules the next update immediately,\n"
+ "expecting the blocking swap to throttle the thread.\n"
+ "This shows how unnecessary the timer is in most cases.");
QCheckBox *transparent = new QCheckBox("Transparent background", this);
transparent->setToolTip("Toggles Qt::WA_AlwaysStackOnTop and transparent clear color for glClear().\n"
"Note how the button on top stacks incorrectly when enabling this.");
QHBoxLayout *updateLayout = new QHBoxLayout;
updateLayout->addWidget(updateLabel);
updateLayout->addWidget(updateInterval);
+ updateLayout->addWidget(timerBased);
updateLayout->addWidget(transparent);
updateGroupBox->setLayout(updateLayout);
@@ -123,6 +131,8 @@ MainWindow::MainWindow()
connect(transparent, &QCheckBox::toggled, glwidget, &GLWidget::setTransparent);
connect(updateInterval, SIGNAL(valueChanged(int)), this, SLOT(updateIntervalChanged(int)));
+ connect(timerBased, &QCheckBox::toggled, this, &MainWindow::timerUsageChanged);
+ connect(timerBased, &QCheckBox::toggled, updateInterval, &QWidget::setEnabled);
m_timer->start();
}
@@ -130,7 +140,8 @@ MainWindow::MainWindow()
void MainWindow::updateIntervalChanged(int value)
{
m_timer->setInterval(value);
- m_timer->start();
+ if (m_timer->isActive())
+ m_timer->start();
}
void MainWindow::addNew()
@@ -138,6 +149,7 @@ void MainWindow::addNew()
if (m_nextY == 4)
return;
GLWidget *w = new GLWidget(this, false, qRgb(qrand() % 256, qrand() % 256, qrand() % 256));
+ m_glWidgets << w;
connect(m_timer, SIGNAL(timeout()), w, SLOT(update()));
m_layout->addWidget(w, m_nextY, m_nextX, 1, 1);
if (m_nextX == 3) {
@@ -147,3 +159,14 @@ void MainWindow::addNew()
++m_nextX;
}
}
+
+void MainWindow::timerUsageChanged(bool enabled)
+{
+ if (enabled) {
+ m_timer->start();
+ } else {
+ m_timer->stop();
+ foreach (QOpenGLWidget *w, m_glWidgets)
+ w->update();
+ }
+}
diff --git a/examples/opengl/qopenglwidget/mainwindow.h b/examples/opengl/qopenglwidget/mainwindow.h
index 9db3e8cbec..353586c42c 100644
--- a/examples/opengl/qopenglwidget/mainwindow.h
+++ b/examples/opengl/qopenglwidget/mainwindow.h
@@ -45,6 +45,8 @@
#include <QTimer>
#include <QGridLayout>
+QT_FORWARD_DECLARE_CLASS(QOpenGLWidget)
+
class MainWindow : public QMainWindow
{
Q_OBJECT
@@ -52,15 +54,18 @@ class MainWindow : public QMainWindow
public:
MainWindow();
void addNew();
+ bool timerEnabled() const { return m_timer->isActive(); }
private slots:
void updateIntervalChanged(int value);
+ void timerUsageChanged(bool enabled);
private:
QTimer *m_timer;
QGridLayout *m_layout;
int m_nextX;
int m_nextY;
+ QVector<QOpenGLWidget *> m_glWidgets;
};
#endif
diff --git a/examples/widgets/doc/src/echoplugin.qdoc b/examples/widgets/doc/src/echoplugin.qdoc
index 103a51cf93..1e10ac3006 100644
--- a/examples/widgets/doc/src/echoplugin.qdoc
+++ b/examples/widgets/doc/src/echoplugin.qdoc
@@ -192,7 +192,7 @@
the platform. By convention the target should have the same name
as the plugin (set with Q_EXPORT_PLUGIN2)
- \section1 Further reading and examples
+ \section1 Further Reading and Examples
The \l {qtplugin-defining-plugins}{Defining Plugins} page presents an overview of the macros needed to
create plugins.
diff --git a/examples/widgets/doc/src/styleplugin.qdoc b/examples/widgets/doc/src/styleplugin.qdoc
index e65ded36a4..2eae6017a5 100644
--- a/examples/widgets/doc/src/styleplugin.qdoc
+++ b/examples/widgets/doc/src/styleplugin.qdoc
@@ -123,7 +123,7 @@
styles folder under stylewindow because this is a path in which Qt
will search for style plugins.
- \section1 Related articles and examples
+ \section1 Related Articles and Examples
In addition to the plugin \l{How to Create Qt Plugins}{overview
document}, we have other examples and articles that concern
diff --git a/examples/widgets/doc/src/tooltips.qdoc b/examples/widgets/doc/src/tooltips.qdoc
index bba19aeac7..4212e62b14 100644
--- a/examples/widgets/doc/src/tooltips.qdoc
+++ b/examples/widgets/doc/src/tooltips.qdoc
@@ -61,7 +61,7 @@
First we will review the \c SortingBox class, then we will take a
look at the \c ShapeItem class.
- \section1 SortingBox Class Definition
+ \section1 SortingBox Class Definition
\snippet widgets/tooltips/sortingbox.h 0
diff --git a/examples/widgets/widgets/mousebuttons/mousebuttons.pro b/examples/widgets/widgets/mousebuttons/mousebuttons.pro
index 99ab9f68ae..e1f4b9527d 100644
--- a/examples/widgets/widgets/mousebuttons/mousebuttons.pro
+++ b/examples/widgets/widgets/mousebuttons/mousebuttons.pro
@@ -1,6 +1,6 @@
TEMPLATE = app
-TARGET = buttontester
+TARGET = mousebuttons
TEMPLATE = app
SOURCES += \