summaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
Diffstat (limited to 'examples')
-rw-r--r--examples/network/torrent/mainwindow.cpp4
-rw-r--r--examples/opengl/hellogl_es2/glwidget.cpp2
-rw-r--r--examples/opengl/hellogl_es2/glwidget.h11
-rw-r--r--examples/opengl/hellowindow/hellowindow.cpp2
-rw-r--r--examples/opengl/opengl.pro8
-rw-r--r--examples/widgets/graphicsview/graphicsview.pro2
-rw-r--r--examples/widgets/itemviews/simpletreemodel/treeitem.cpp24
-rw-r--r--examples/widgets/itemviews/simpletreemodel/treeitem.h10
-rw-r--r--examples/widgets/itemviews/simpletreemodel/treemodel.cpp2
-rw-r--r--examples/widgets/mainwindows/mainwindow/mainwindow.cpp13
-rw-r--r--examples/widgets/painting/composition/composition.cpp12
-rw-r--r--examples/widgets/painting/composition/composition.pro6
-rw-r--r--examples/widgets/richtext/textedit/textedit.cpp4
-rw-r--r--examples/widgets/widgets/wiggly/dialog.cpp22
-rw-r--r--examples/widgets/widgets/wiggly/dialog.h4
-rw-r--r--examples/widgets/widgets/wiggly/main.cpp11
16 files changed, 77 insertions, 60 deletions
diff --git a/examples/network/torrent/mainwindow.cpp b/examples/network/torrent/mainwindow.cpp
index 649dbb0a77..3ac7d9dfdd 100644
--- a/examples/network/torrent/mainwindow.cpp
+++ b/examples/network/torrent/mainwindow.cpp
@@ -173,6 +173,10 @@ MainWindow::MainWindow(QWidget *parent)
bottomBar->addWidget((uploadLimitLabel = new QLabel(tr("0 KB/s"))));
uploadLimitLabel->setFixedSize(QSize(fm.width(tr("99999 KB/s")), fm.lineSpacing()));
+#ifdef Q_OS_OSX
+ setUnifiedTitleAndToolBarOnMac(true);
+#endif
+
// Set up connections
connect(torrentView, SIGNAL(itemSelectionChanged()),
this, SLOT(setActionsEnabled()));
diff --git a/examples/opengl/hellogl_es2/glwidget.cpp b/examples/opengl/hellogl_es2/glwidget.cpp
index 7267cfd124..733475d321 100644
--- a/examples/opengl/hellogl_es2/glwidget.cpp
+++ b/examples/opengl/hellogl_es2/glwidget.cpp
@@ -171,6 +171,8 @@ void GLWidget::paintTexturedCube()
void GLWidget::initializeGL ()
{
+ initializeOpenGLFunctions();
+
glClearColor(0.1f, 0.1f, 0.2f, 1.0f);
glGenTextures(1, &m_uiTexture);
diff --git a/examples/opengl/hellogl_es2/glwidget.h b/examples/opengl/hellogl_es2/glwidget.h
index 8ed86b1e01..00073aa047 100644
--- a/examples/opengl/hellogl_es2/glwidget.h
+++ b/examples/opengl/hellogl_es2/glwidget.h
@@ -42,15 +42,16 @@
#define GLWIDGET_H
#include <QGLWidget>
-#include <QtGui/qvector3d.h>
-#include <QtGui/qmatrix4x4.h>
-#include <QtOpenGL/qglshaderprogram.h>
+#include <QOpenGLFunctions>
+#include <QGLShaderProgram>
+#include <QVector3D>
+#include <QMatrix4x4>
#include <QTime>
#include <QVector>
class Bubble;
-class GLWidget : public QGLWidget {
-
+class GLWidget : public QGLWidget, protected QOpenGLFunctions
+{
Q_OBJECT
public:
GLWidget(QWidget *parent = 0);
diff --git a/examples/opengl/hellowindow/hellowindow.cpp b/examples/opengl/hellowindow/hellowindow.cpp
index 3b5971c0d3..b4dc4464ba 100644
--- a/examples/opengl/hellowindow/hellowindow.cpp
+++ b/examples/opengl/hellowindow/hellowindow.cpp
@@ -182,7 +182,7 @@ void Renderer::paintQtLogo()
m_program->enableAttributeArray(vertexAttr);
m_program->setAttributeArray(vertexAttr, vertices.constData());
m_program->setAttributeArray(normalAttr, normals.constData());
- glDrawArrays(GL_TRIANGLES, 0, vertices.size());
+ m_context->functions()->glDrawArrays(GL_TRIANGLES, 0, vertices.size());
m_program->disableAttributeArray(normalAttr);
m_program->disableAttributeArray(vertexAttr);
}
diff --git a/examples/opengl/opengl.pro b/examples/opengl/opengl.pro
index 7bc96234df..aea281ce5c 100644
--- a/examples/opengl/opengl.pro
+++ b/examples/opengl/opengl.pro
@@ -2,7 +2,11 @@ requires(qtHaveModule(opengl))
TEMPLATE = subdirs
-contains(QT_CONFIG, opengles2) {
+contains(QT_CONFIG, dynamicgl) {
+ SUBDIRS = hellowindow \
+ contextinfo \
+ hellogl_es2
+} else: contains(QT_CONFIG, opengles2){
SUBDIRS = hellogl_es2
} else {
SUBDIRS = 2dpainting \
@@ -14,7 +18,7 @@ contains(QT_CONFIG, opengles2) {
samplebuffers
}
-SUBDIRS += hellowindow \
+!contains(QT_CONFIG, dynamicgl): SUBDIRS += hellowindow \
paintedwindow \
contextinfo \
cube \
diff --git a/examples/widgets/graphicsview/graphicsview.pro b/examples/widgets/graphicsview/graphicsview.pro
index 9d6d7a75f6..06a7ce8071 100644
--- a/examples/widgets/graphicsview/graphicsview.pro
+++ b/examples/widgets/graphicsview/graphicsview.pro
@@ -15,6 +15,6 @@ SUBDIRS = \
contains(DEFINES, QT_NO_CURSOR)|contains(DEFINES, QT_NO_DRAGANDDROP): SUBDIRS -= dragdroprobot
-qtHaveModule(opengl):!contains(QT_CONFIG, opengles.) {
+qtHaveModule(opengl):!contains(QT_CONFIG, opengles.):!contains(QT_CONFIG,dynamicgl) {
SUBDIRS += boxes
}
diff --git a/examples/widgets/itemviews/simpletreemodel/treeitem.cpp b/examples/widgets/itemviews/simpletreemodel/treeitem.cpp
index f48a840a00..a5feac3178 100644
--- a/examples/widgets/itemviews/simpletreemodel/treeitem.cpp
+++ b/examples/widgets/itemviews/simpletreemodel/treeitem.cpp
@@ -51,65 +51,65 @@
//! [0]
TreeItem::TreeItem(const QList<QVariant> &data, TreeItem *parent)
{
- parentItem = parent;
- itemData = data;
+ m_parentItem = parent;
+ m_itemData = data;
}
//! [0]
//! [1]
TreeItem::~TreeItem()
{
- qDeleteAll(childItems);
+ qDeleteAll(m_childItems);
}
//! [1]
//! [2]
void TreeItem::appendChild(TreeItem *item)
{
- childItems.append(item);
+ m_childItems.append(item);
}
//! [2]
//! [3]
TreeItem *TreeItem::child(int row)
{
- return childItems.value(row);
+ return m_childItems.value(row);
}
//! [3]
//! [4]
int TreeItem::childCount() const
{
- return childItems.count();
+ return m_childItems.count();
}
//! [4]
//! [5]
int TreeItem::columnCount() const
{
- return itemData.count();
+ return m_itemData.count();
}
//! [5]
//! [6]
QVariant TreeItem::data(int column) const
{
- return itemData.value(column);
+ return m_itemData.value(column);
}
//! [6]
//! [7]
-TreeItem *TreeItem::parent()
+TreeItem *TreeItem::parentItem()
{
- return parentItem;
+ return m_parentItem;
}
//! [7]
//! [8]
int TreeItem::row() const
{
- if (parentItem)
- return parentItem->childItems.indexOf(const_cast<TreeItem*>(this));
+ if (m_parentItem)
+ return m_parentItem->m_childItems.indexOf(const_cast<TreeItem*>(this));
return 0;
}
diff --git a/examples/widgets/itemviews/simpletreemodel/treeitem.h b/examples/widgets/itemviews/simpletreemodel/treeitem.h
index e775b5083e..33dbd8b993 100644
--- a/examples/widgets/itemviews/simpletreemodel/treeitem.h
+++ b/examples/widgets/itemviews/simpletreemodel/treeitem.h
@@ -48,7 +48,7 @@
class TreeItem
{
public:
- explicit TreeItem(const QList<QVariant> &data, TreeItem *parent = 0);
+ explicit TreeItem(const QList<QVariant> &data, TreeItem *parentItem = 0);
~TreeItem();
void appendChild(TreeItem *child);
@@ -58,12 +58,12 @@ public:
int columnCount() const;
QVariant data(int column) const;
int row() const;
- TreeItem *parent();
+ TreeItem *parentItem();
private:
- QList<TreeItem*> childItems;
- QList<QVariant> itemData;
- TreeItem *parentItem;
+ QList<TreeItem*> m_childItems;
+ QList<QVariant> m_itemData;
+ TreeItem *m_parentItem;
};
//! [0]
diff --git a/examples/widgets/itemviews/simpletreemodel/treemodel.cpp b/examples/widgets/itemviews/simpletreemodel/treemodel.cpp
index 971a813328..b15a717ef2 100644
--- a/examples/widgets/itemviews/simpletreemodel/treemodel.cpp
+++ b/examples/widgets/itemviews/simpletreemodel/treemodel.cpp
@@ -143,7 +143,7 @@ QModelIndex TreeModel::parent(const QModelIndex &index) const
return QModelIndex();
TreeItem *childItem = static_cast<TreeItem*>(index.internalPointer());
- TreeItem *parentItem = childItem->parent();
+ TreeItem *parentItem = childItem->parentItem();
if (parentItem == rootItem)
return QModelIndex();
diff --git a/examples/widgets/mainwindows/mainwindow/mainwindow.cpp b/examples/widgets/mainwindows/mainwindow/mainwindow.cpp
index fe54f4569a..0a29edee74 100644
--- a/examples/widgets/mainwindows/mainwindow/mainwindow.cpp
+++ b/examples/widgets/mainwindows/mainwindow/mainwindow.cpp
@@ -109,6 +109,10 @@ void MainWindow::actionTriggered(QAction *action)
void MainWindow::setupToolBar()
{
+#ifdef Q_OS_OSX
+ setUnifiedTitleAndToolBarOnMac(true);
+#endif
+
for (int i = 0; i < 3; ++i) {
ToolBar *tb = new ToolBar(QString::fromLatin1("Tool Bar %1").arg(i + 1), this);
toolBars.append(tb);
@@ -164,6 +168,15 @@ void MainWindow::setupMenuBar()
for (int i = 0; i < toolBars.count(); ++i)
toolBarMenu->addMenu(toolBars.at(i)->menu);
+#ifdef Q_OS_OSX
+ toolBarMenu->addSeparator();
+
+ action = toolBarMenu->addAction(tr("Unified"));
+ action->setCheckable(true);
+ action->setChecked(unifiedTitleAndToolBarOnMac());
+ connect(action, SIGNAL(toggled(bool)), this, SLOT(setUnifiedTitleAndToolBarOnMac(bool)));
+#endif
+
dockWidgetMenu = menuBar()->addMenu(tr("&Dock Widgets"));
}
diff --git a/examples/widgets/painting/composition/composition.cpp b/examples/widgets/painting/composition/composition.cpp
index d89f9d5fb1..a591cafd06 100644
--- a/examples/widgets/painting/composition/composition.cpp
+++ b/examples/widgets/painting/composition/composition.cpp
@@ -127,7 +127,7 @@ CompositionWidget::CompositionWidget(QWidget *parent)
QPushButton *showSourceButton = new QPushButton(mainGroup);
showSourceButton->setText(tr("Show Source"));
-#if defined(QT_OPENGL_SUPPORT) && !defined(QT_OPENGL_ES)
+#if defined(USE_OPENGL) && !defined(QT_OPENGL_ES)
QPushButton *enableOpenGLButton = new QPushButton(mainGroup);
enableOpenGLButton->setText(tr("Use OpenGL"));
enableOpenGLButton->setCheckable(true);
@@ -157,7 +157,7 @@ CompositionWidget::CompositionWidget(QWidget *parent)
mainGroupLayout->addWidget(animateButton);
mainGroupLayout->addWidget(whatsThisButton);
mainGroupLayout->addWidget(showSourceButton);
-#if defined(QT_OPENGL_SUPPORT) && !defined(QT_OPENGL_ES)
+#if defined(USE_OPENGL) && !defined(QT_OPENGL_ES)
mainGroupLayout->addWidget(enableOpenGLButton);
#endif
@@ -201,7 +201,7 @@ CompositionWidget::CompositionWidget(QWidget *parent)
connect(whatsThisButton, SIGNAL(clicked(bool)), view, SLOT(setDescriptionEnabled(bool)));
connect(view, SIGNAL(descriptionEnabledChanged(bool)), whatsThisButton, SLOT(setChecked(bool)));
connect(showSourceButton, SIGNAL(clicked()), view, SLOT(showSource()));
-#if defined(QT_OPENGL_SUPPORT) && !defined(QT_OPENGL_ES)
+#if defined(USE_OPENGL) && !defined(QT_OPENGL_ES)
connect(enableOpenGLButton, SIGNAL(clicked(bool)), view, SLOT(enableOpenGL(bool)));
#endif
connect(animateButton, SIGNAL(toggled(bool)), view, SLOT(setAnimationEnabled(bool)));
@@ -249,7 +249,7 @@ CompositionRenderer::CompositionRenderer(QWidget *parent)
m_circle_pos = QPoint(200, 100);
setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
-#ifdef QT_OPENGL_SUPPORT
+#ifdef USE_OPENGL
m_pbuffer = 0;
m_pbuffer_size = 1024;
#endif
@@ -341,7 +341,7 @@ void CompositionRenderer::drawSource(QPainter &p)
void CompositionRenderer::paint(QPainter *painter)
{
-#if defined(QT_OPENGL_SUPPORT) && !defined(QT_OPENGL_ES)
+#if defined(USE_OPENGL) && !defined(QT_OPENGL_ES)
if (usesOpenGL()) {
int new_pbuf_size = m_pbuffer_size;
@@ -511,7 +511,7 @@ void CompositionRenderer::setCirclePos(const QPointF &pos)
const QRect oldRect = rectangle_around(m_circle_pos).toAlignedRect();
m_circle_pos = pos;
const QRect newRect = rectangle_around(m_circle_pos).toAlignedRect();
-#if defined(QT_OPENGL_SUPPORT) && !defined(QT_OPENGL_ES)
+#if defined(USE_OPENGL) && !defined(QT_OPENGL_ES)
if (usesOpenGL()) {
update();
return;
diff --git a/examples/widgets/painting/composition/composition.pro b/examples/widgets/painting/composition/composition.pro
index 0269945ac8..332291c2a4 100644
--- a/examples/widgets/painting/composition/composition.pro
+++ b/examples/widgets/painting/composition/composition.pro
@@ -6,9 +6,9 @@ SHARED_FOLDER = ../shared
include($$SHARED_FOLDER/shared.pri)
RESOURCES += composition.qrc
-qtHaveModule(opengl) {
- DEFINES += QT_OPENGL_SUPPORT
- QT += opengl
+qtHaveModule(opengl): !contains(QT_CONFIG,dynamicgl) {
+ DEFINES += USE_OPENGL
+ QT += opengl
}
QT += widgets
diff --git a/examples/widgets/richtext/textedit/textedit.cpp b/examples/widgets/richtext/textedit/textedit.cpp
index 128924ef4e..2ff7a09969 100644
--- a/examples/widgets/richtext/textedit/textedit.cpp
+++ b/examples/widgets/richtext/textedit/textedit.cpp
@@ -78,6 +78,10 @@ const QString rsrcPath = ":/images/win";
TextEdit::TextEdit(QWidget *parent)
: QMainWindow(parent)
{
+#ifdef Q_OS_OSX
+ setUnifiedTitleAndToolBarOnMac(true);
+#endif
+
setToolButtonStyle(Qt::ToolButtonFollowStyle);
setupFileActions();
setupEditActions();
diff --git a/examples/widgets/widgets/wiggly/dialog.cpp b/examples/widgets/widgets/wiggly/dialog.cpp
index 1279d9d05b..3bb4f60d76 100644
--- a/examples/widgets/widgets/wiggly/dialog.cpp
+++ b/examples/widgets/widgets/wiggly/dialog.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** This file is part of the examples of the Qt Toolkit.
@@ -38,32 +38,26 @@
**
****************************************************************************/
-#include <QtWidgets>
-#include <QtWidgets>
+#include <QLineEdit>
+#include <QVBoxLayout>
#include "dialog.h"
#include "wigglywidget.h"
//! [0]
-Dialog::Dialog(QWidget *parent, bool smallScreen)
+Dialog::Dialog(QWidget *parent)
: QDialog(parent)
{
WigglyWidget *wigglyWidget = new WigglyWidget;
QLineEdit *lineEdit = new QLineEdit;
- QVBoxLayout *layout = new QVBoxLayout;
+ QVBoxLayout *layout = new QVBoxLayout(this);
layout->addWidget(wigglyWidget);
layout->addWidget(lineEdit);
- setLayout(layout);
- connect(lineEdit, SIGNAL(textChanged(QString)),
- wigglyWidget, SLOT(setText(QString)));
- if (!smallScreen){
- lineEdit->setText(tr("Hello world!"));
- }
- else{
- lineEdit->setText(tr("Hello!"));
- }
+ connect(lineEdit, &QLineEdit::textChanged, wigglyWidget, &WigglyWidget::setText);
+ lineEdit->setText(tr("Hello world!"));
+
setWindowTitle(tr("Wiggly"));
resize(360, 145);
}
diff --git a/examples/widgets/widgets/wiggly/dialog.h b/examples/widgets/widgets/wiggly/dialog.h
index 7355a56887..885671c69e 100644
--- a/examples/widgets/widgets/wiggly/dialog.h
+++ b/examples/widgets/widgets/wiggly/dialog.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** This file is part of the examples of the Qt Toolkit.
@@ -49,7 +49,7 @@ class Dialog : public QDialog
Q_OBJECT
public:
- explicit Dialog(QWidget *parent = 0, bool smallScreen = false);
+ explicit Dialog(QWidget *parent = 0);
};
//! [0]
diff --git a/examples/widgets/widgets/wiggly/main.cpp b/examples/widgets/widgets/wiggly/main.cpp
index df5d5487bc..caf00eb748 100644
--- a/examples/widgets/widgets/wiggly/main.cpp
+++ b/examples/widgets/widgets/wiggly/main.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** This file is part of the examples of the Qt Toolkit.
@@ -45,14 +45,9 @@
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
- bool smallScreen = QApplication::arguments().contains("-small-screen");
+ Dialog dialog;
+ dialog.show();
- Dialog dialog(0, smallScreen);
-
- if (!smallScreen)
- dialog.show();
- else
- dialog.showFullScreen();
return app.exec();
}