summaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
Diffstat (limited to 'examples')
-rw-r--r--examples/animation/moveblocks/main.cpp2
-rw-r--r--examples/opengl/cube/cube.pro9
-rw-r--r--examples/sql/sqlbrowser/browser.cpp75
-rw-r--r--examples/sql/sqlbrowser/browser.h20
-rw-r--r--examples/sql/sqlbrowser/browserwidget.ui184
-rw-r--r--examples/webkit/webkit-guide/_index.html2
-rw-r--r--examples/widgets/mousebuttons/buttontester.cpp172
-rw-r--r--examples/widgets/mousebuttons/buttontester.h64
-rw-r--r--examples/widgets/mousebuttons/main.cpp66
-rw-r--r--examples/widgets/mousebuttons/mousebuttons.pro18
-rw-r--r--examples/widgets/widgets.pro1
11 files changed, 523 insertions, 90 deletions
diff --git a/examples/animation/moveblocks/main.cpp b/examples/animation/moveblocks/main.cpp
index 8e7c04e9f0..d807bb63d9 100644
--- a/examples/animation/moveblocks/main.cpp
+++ b/examples/animation/moveblocks/main.cpp
@@ -50,7 +50,7 @@ public:
{
}
- StateSwitchEvent(int rand)
+ explicit StateSwitchEvent(int rand)
: QEvent(Type(StateSwitchType)),
m_rand(rand)
{
diff --git a/examples/opengl/cube/cube.pro b/examples/opengl/cube/cube.pro
index ef6f526067..98a3082340 100644
--- a/examples/opengl/cube/cube.pro
+++ b/examples/opengl/cube/cube.pro
@@ -1,9 +1,3 @@
-#-------------------------------------------------
-#
-# Project created by QtCreator 2010-06-23T12:55:35
-#
-#-------------------------------------------------
-
QT += core gui widgets
TARGET = cube
@@ -12,7 +6,6 @@ TEMPLATE = app
SOURCES += main.cpp
contains(QT_CONFIG, opengl) {
- message(Building with OpenGL support.)
QT += opengl
SOURCES += mainwidget.cpp \
@@ -29,8 +22,6 @@ contains(QT_CONFIG, opengl) {
OTHER_FILES += \
vshader.glsl \
fshader.glsl
-} else {
- message(OpenGL support is not available.)
}
diff --git a/examples/sql/sqlbrowser/browser.cpp b/examples/sql/sqlbrowser/browser.cpp
index 3aa330e227..eaaec25b16 100644
--- a/examples/sql/sqlbrowser/browser.cpp
+++ b/examples/sql/sqlbrowser/browser.cpp
@@ -52,6 +52,12 @@ Browser::Browser(QWidget *parent)
table->addAction(insertRowAction);
table->addAction(deleteRowAction);
+ table->addAction(fieldStrategyAction);
+ table->addAction(rowStrategyAction);
+ table->addAction(manualStrategyAction);
+ table->addAction(submitAction);
+ table->addAction(revertAction);
+ table->addAction(selectAction);
if (QSqlDatabase::drivers().isEmpty())
QMessageBox::information(this, tr("No database drivers found"),
@@ -144,7 +150,7 @@ void Browser::addConnection()
void Browser::showTable(const QString &t)
{
- QSqlTableModel *model = new QSqlTableModel(table, connectionWidget->currentDatabase());
+ QSqlTableModel *model = new CustomModel(table, connectionWidget->currentDatabase());
model->setEditStrategy(QSqlTableModel::OnRowChange);
model->setTable(connectionWidget->currentDatabase().driver()->escapeIdentifier(t, QSqlDriver::TableName));
model->select();
@@ -215,8 +221,6 @@ void Browser::deleteRow()
if (!model)
return;
- model->setEditStrategy(QSqlTableModel::OnManualSubmit);
-
QModelIndexList currentSelection = table->selectionModel()->selectedIndexes();
for (int i = 0; i < currentSelection.count(); ++i) {
if (currentSelection.at(i).column() != 0)
@@ -224,24 +228,79 @@ void Browser::deleteRow()
model->removeRow(currentSelection.at(i).row());
}
- model->submitAll();
- model->setEditStrategy(QSqlTableModel::OnRowChange);
-
updateActions();
}
void Browser::updateActions()
{
- bool enableIns = qobject_cast<QSqlTableModel *>(table->model());
+ QSqlTableModel * tm = qobject_cast<QSqlTableModel *>(table->model());
+ bool enableIns = tm;
bool enableDel = enableIns && table->currentIndex().isValid();
insertRowAction->setEnabled(enableIns);
deleteRowAction->setEnabled(enableDel);
+
+ fieldStrategyAction->setEnabled(tm);
+ rowStrategyAction->setEnabled(tm);
+ manualStrategyAction->setEnabled(tm);
+ submitAction->setEnabled(tm);
+ revertAction->setEnabled(tm);
+ selectAction->setEnabled(tm);
+
+ if (tm) {
+ QSqlTableModel::EditStrategy es = tm->editStrategy();
+ fieldStrategyAction->setChecked(es == QSqlTableModel::OnFieldChange);
+ rowStrategyAction->setChecked(es == QSqlTableModel::OnRowChange);
+ manualStrategyAction->setChecked(es == QSqlTableModel::OnManualSubmit);
+ }
}
void Browser::about()
{
QMessageBox::about(this, tr("About"), tr("The SQL Browser demonstration "
"shows how a data browser can be used to visualize the results of SQL"
- "statements on a live database"));
+ "statements on a live database"));
+}
+
+void Browser::on_fieldStrategyAction_triggered()
+{
+ QSqlTableModel * tm = qobject_cast<QSqlTableModel *>(table->model());
+ if (tm)
+ tm->setEditStrategy(QSqlTableModel::OnFieldChange);
+}
+
+void Browser::on_rowStrategyAction_triggered()
+{
+ QSqlTableModel * tm = qobject_cast<QSqlTableModel *>(table->model());
+ if (tm)
+ tm->setEditStrategy(QSqlTableModel::OnRowChange);
+}
+
+void Browser::on_manualStrategyAction_triggered()
+{
+ QSqlTableModel * tm = qobject_cast<QSqlTableModel *>(table->model());
+ if (tm)
+ tm->setEditStrategy(QSqlTableModel::OnManualSubmit);
+}
+
+void Browser::on_submitAction_triggered()
+{
+ QSqlTableModel * tm = qobject_cast<QSqlTableModel *>(table->model());
+ if (tm)
+ tm->submitAll();
+}
+
+void Browser::on_revertAction_triggered()
+{
+ QSqlTableModel * tm = qobject_cast<QSqlTableModel *>(table->model());
+ if (tm)
+ tm->revertAll();
+}
+
+void Browser::on_selectAction_triggered()
+{
+ QSqlTableModel * tm = qobject_cast<QSqlTableModel *>(table->model());
+ if (tm)
+ tm->select();
}
+
diff --git a/examples/sql/sqlbrowser/browser.h b/examples/sql/sqlbrowser/browser.h
index 0769812ec8..e9f45345df 100644
--- a/examples/sql/sqlbrowser/browser.h
+++ b/examples/sql/sqlbrowser/browser.h
@@ -43,6 +43,7 @@
#define BROWSER_H
#include <QWidget>
+#include <QSqlTableModel>
#include "ui_browserwidget.h"
class ConnectionWidget;
@@ -77,6 +78,12 @@ public slots:
{ insertRow(); }
void on_deleteRowAction_triggered()
{ deleteRow(); }
+ void on_fieldStrategyAction_triggered();
+ void on_rowStrategyAction_triggered();
+ void on_manualStrategyAction_triggered();
+ void on_submitAction_triggered();
+ void on_revertAction_triggered();
+ void on_selectAction_triggered();
void on_connectionWidget_tableActivated(const QString &table)
{ showTable(table); }
void on_connectionWidget_metaDataRequested(const QString &table)
@@ -96,4 +103,17 @@ signals:
void statusMessage(const QString &message);
};
+class CustomModel: public QSqlTableModel
+{
+ Q_OBJECT
+public:
+ CustomModel(QObject *parent = 0, QSqlDatabase db = QSqlDatabase()):QSqlTableModel(parent, db) {}
+ QVariant data(const QModelIndex &idx, int role) const
+ {
+ if (role == Qt::BackgroundRole && isDirty(idx))
+ return QBrush(QColor(Qt::yellow));
+ return QSqlTableModel::data(idx, role);
+ }
+};
+
#endif
diff --git a/examples/sql/sqlbrowser/browserwidget.ui b/examples/sql/sqlbrowser/browserwidget.ui
index 20946f0ede..ff65b1f199 100644
--- a/examples/sql/sqlbrowser/browserwidget.ui
+++ b/examples/sql/sqlbrowser/browserwidget.ui
@@ -1,10 +1,8 @@
-<ui version="4.0" >
- <author></author>
- <comment></comment>
- <exportmacro></exportmacro>
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
<class>Browser</class>
- <widget class="QWidget" name="Browser" >
- <property name="geometry" >
+ <widget class="QWidget" name="Browser">
+ <property name="geometry">
<rect>
<x>0</x>
<y>0</y>
@@ -12,100 +10,90 @@
<height>515</height>
</rect>
</property>
- <property name="windowTitle" >
+ <property name="windowTitle">
<string>Qt SQL Browser</string>
</property>
- <layout class="QVBoxLayout" >
- <property name="margin" >
- <number>8</number>
- </property>
- <property name="spacing" >
+ <layout class="QVBoxLayout">
+ <property name="spacing">
<number>6</number>
</property>
+ <property name="margin">
+ <number>8</number>
+ </property>
<item>
- <widget class="QSplitter" name="splitter_2" >
- <property name="sizePolicy" >
- <sizepolicy>
- <hsizetype>7</hsizetype>
- <vsizetype>7</vsizetype>
+ <widget class="QSplitter" name="splitter_2">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
- <property name="orientation" >
+ <property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
- <widget class="ConnectionWidget" name="connectionWidget" >
- <property name="sizePolicy" >
- <sizepolicy>
- <hsizetype>13</hsizetype>
- <vsizetype>7</vsizetype>
+ <widget class="ConnectionWidget" name="connectionWidget">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Ignored" vsizetype="Expanding">
<horstretch>1</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
- <widget class="QTableView" name="table" >
- <property name="sizePolicy" >
- <sizepolicy>
- <hsizetype>7</hsizetype>
- <vsizetype>7</vsizetype>
+ <widget class="QTableView" name="table">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>2</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
- <property name="contextMenuPolicy" >
+ <property name="contextMenuPolicy">
<enum>Qt::ActionsContextMenu</enum>
</property>
- <property name="selectionBehavior" >
+ <property name="selectionBehavior">
<enum>QAbstractItemView::SelectRows</enum>
</property>
</widget>
</widget>
</item>
<item>
- <widget class="QGroupBox" name="groupBox" >
- <property name="sizePolicy" >
- <sizepolicy>
- <hsizetype>5</hsizetype>
- <vsizetype>3</vsizetype>
+ <widget class="QGroupBox" name="groupBox">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Preferred" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
- <property name="maximumSize" >
+ <property name="maximumSize">
<size>
<width>16777215</width>
<height>180</height>
</size>
</property>
- <property name="title" >
+ <property name="title">
<string>SQL Query</string>
</property>
- <layout class="QVBoxLayout" >
- <property name="margin" >
- <number>9</number>
- </property>
- <property name="spacing" >
+ <layout class="QVBoxLayout">
+ <property name="spacing">
<number>6</number>
</property>
+ <property name="margin">
+ <number>9</number>
+ </property>
<item>
- <widget class="QTextEdit" name="sqlEdit" >
- <property name="sizePolicy" >
- <sizepolicy>
- <hsizetype>7</hsizetype>
- <vsizetype>3</vsizetype>
+ <widget class="QTextEdit" name="sqlEdit">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Expanding" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
- <property name="minimumSize" >
+ <property name="minimumSize">
<size>
<width>0</width>
<height>18</height>
</size>
</property>
- <property name="baseSize" >
+ <property name="baseSize">
<size>
<width>0</width>
<height>120</height>
@@ -114,19 +102,19 @@
</widget>
</item>
<item>
- <layout class="QHBoxLayout" >
- <property name="margin" >
- <number>1</number>
- </property>
- <property name="spacing" >
+ <layout class="QHBoxLayout">
+ <property name="spacing">
<number>6</number>
</property>
+ <property name="margin">
+ <number>1</number>
+ </property>
<item>
<spacer>
- <property name="orientation" >
+ <property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
- <property name="sizeHint" >
+ <property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
@@ -135,15 +123,15 @@
</spacer>
</item>
<item>
- <widget class="QPushButton" name="clearButton" >
- <property name="text" >
+ <widget class="QPushButton" name="clearButton">
+ <property name="text">
<string>&amp;Clear</string>
</property>
</widget>
</item>
<item>
- <widget class="QPushButton" name="submitButton" >
- <property name="text" >
+ <widget class="QPushButton" name="submitButton">
+ <property name="text">
<string>&amp;Submit</string>
</property>
</widget>
@@ -154,37 +142,91 @@
</widget>
</item>
</layout>
- <action name="insertRowAction" >
- <property name="enabled" >
+ <action name="insertRowAction">
+ <property name="enabled">
<bool>false</bool>
</property>
- <property name="text" >
+ <property name="text">
<string>&amp;Insert Row</string>
</property>
- <property name="statusTip" >
+ <property name="statusTip">
<string>Inserts a new Row</string>
</property>
</action>
- <action name="deleteRowAction" >
- <property name="enabled" >
+ <action name="deleteRowAction">
+ <property name="enabled">
<bool>false</bool>
</property>
- <property name="text" >
+ <property name="text">
<string>&amp;Delete Row</string>
</property>
- <property name="statusTip" >
+ <property name="statusTip">
<string>Deletes the current Row</string>
</property>
</action>
+ <action name="fieldStrategyAction">
+ <property name="checkable">
+ <bool>true</bool>
+ </property>
+ <property name="text">
+ <string>Submit on &amp;Field Change</string>
+ </property>
+ <property name="toolTip">
+ <string>Commit on Field Change</string>
+ </property>
+ </action>
+ <action name="rowStrategyAction">
+ <property name="checkable">
+ <bool>true</bool>
+ </property>
+ <property name="text">
+ <string>Submit on &amp;Row Change</string>
+ </property>
+ <property name="toolTip">
+ <string>Commit on Row Change</string>
+ </property>
+ </action>
+ <action name="manualStrategyAction">
+ <property name="checkable">
+ <bool>true</bool>
+ </property>
+ <property name="text">
+ <string>Submit &amp;Manually</string>
+ </property>
+ <property name="toolTip">
+ <string>Commit Manually</string>
+ </property>
+ </action>
+ <action name="submitAction">
+ <property name="text">
+ <string>&amp;Submit All</string>
+ </property>
+ <property name="toolTip">
+ <string>Submit Changes</string>
+ </property>
+ </action>
+ <action name="revertAction">
+ <property name="text">
+ <string>&amp;Revert All</string>
+ </property>
+ <property name="toolTip">
+ <string>Revert</string>
+ </property>
+ </action>
+ <action name="selectAction">
+ <property name="text">
+ <string>S&amp;elect</string>
+ </property>
+ <property name="toolTip">
+ <string>Refresh Data from Database</string>
+ </property>
+ </action>
</widget>
- <pixmapfunction></pixmapfunction>
<customwidgets>
<customwidget>
<class>ConnectionWidget</class>
<extends>QTreeView</extends>
<header>connectionwidget.h</header>
- <container>0</container>
- <pixmap></pixmap>
</customwidget>
</customwidgets>
<tabstops>
diff --git a/examples/webkit/webkit-guide/_index.html b/examples/webkit/webkit-guide/_index.html
index 5d7dd11d63..f3a1f9dfa6 100644
--- a/examples/webkit/webkit-guide/_index.html
+++ b/examples/webkit/webkit-guide/_index.html
@@ -298,7 +298,7 @@ entered (localStorage), but credit-card data s/b absent
<div id="feedcloseX" class="feedclose t_button">X</div>
<form id="feedform" action="http://doc.qt.nokia.com/docFeedbck/feedback.php" method="get">
<p id="noteHead">Thank you for giving your feedback.</p> <p class="note">Make sure it is related to this specific page. For more general bugs and
- requests, please use the <a href="http://bugreports.qt.nokia.com/secure/Dashboard.jspa">Qt Bug Tracker</a>.</p>
+ requests, please use the <a href="http://bugreports.qt-project.org/secure/Dashboard.jspa">Qt Bug Tracker</a>.</p>
<p><textarea id="feedbox" name="feedText" rows="5" cols="40"></textarea></p>
<p><input id="feedsubmit" class="feedclose" type="submit" name="feedback" /></p>
</form>
diff --git a/examples/widgets/mousebuttons/buttontester.cpp b/examples/widgets/mousebuttons/buttontester.cpp
new file mode 100644
index 0000000000..32f73ebb72
--- /dev/null
+++ b/examples/widgets/mousebuttons/buttontester.cpp
@@ -0,0 +1,172 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Rick Stockton <rickstockton@reno-computerhelp.com>
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "buttontester.h"
+
+void ButtonTester::mousePressEvent(QMouseEvent *e)
+{
+ int j = ButtonTester::buttonByNumber (e->button());
+ QString result = "Mouse Press: raw button=" + QString::number(j) + " Qt=" + enumNameFromValue(e->button());
+ qDebug() << result;
+ this->setText(result);
+ if (j == 2) {
+ this->repaint();
+ }
+}
+
+void ButtonTester::mouseReleaseEvent(QMouseEvent *e)
+{
+ int j = ButtonTester::buttonByNumber (e->button());
+ QString result = "Mouse Release: raw button=" + QString::number(j) + " Qt=" + enumNameFromValue(e->button());
+ qDebug() << result;
+ this->setText(result);
+}
+
+void ButtonTester::mouseDoubleClickEvent(QMouseEvent *e)
+{
+ int j = ButtonTester::buttonByNumber (e->button());
+ QString result = "Mouse DoubleClick: raw button=" + QString::number(j) + " Qt=" + enumNameFromValue(e->button());
+ qDebug() << result;
+ this->setText(result);
+}
+
+void ButtonTester::wheelEvent (QWheelEvent *e)
+{
+ QString result;
+ if (e->delta() > 0) {
+
+ if (e->orientation() == Qt::Vertical) {
+ result = "Mouse Wheel Event: UP";
+ } else {
+ result = "Mouse Wheel Event: LEFT";
+ }
+ } else if (e->delta() < 0) {
+ if (e->orientation() == Qt::Vertical) {
+ result = "Mouse Wheel Event: DOWN";
+ } else {
+ result = "Mouse Wheel Event: RIGHT";
+ }
+ }
+ qDebug() << result;
+ this->setText(result);
+}
+
+int ButtonTester::buttonByNumber(const Qt::MouseButton button)
+{
+ if (button == Qt::NoButton) return 0;
+ if (button == Qt::LeftButton) return 1;
+ if (button == Qt::RightButton) return 2;
+ if (button == Qt::MiddleButton) return 3;
+
+/* Please note that Qt Button #4 corresponds to button #8 on all
+ * platforms which EMULATE wheel events by creating button events
+ * (Button #4 = Scroll Up; Button #5 = Scroll Down; Button #6 = Scroll
+ * Left; and Button #7 = Scroll Right.) This includes X11, with both
+ * Xlib and XCB. So, the "raw button" for "Qt::BackButton" is
+ * usually described as "Button #8".
+
+ * If your platform supports "smooth scrolling", then, for the cases of
+ * Qt::BackButton and higher, this program will show "raw button" with a
+ * value which is too large. Subtract 4 to get the correct button ID for
+ * your platform.
+ */
+
+ if (button == Qt::BackButton) return 8;
+ if (button == Qt::ForwardButton) return 9;
+ if (button == Qt::TaskButton) return 10;
+ if (button == Qt::ExtraButton4) return 11;
+ if (button == Qt::ExtraButton5) return 12;
+ if (button == Qt::ExtraButton6) return 13;
+ if (button == Qt::ExtraButton7) return 14;
+ if (button == Qt::ExtraButton8) return 15;
+ if (button == Qt::ExtraButton9) return 16;
+ if (button == Qt::ExtraButton10) return 17;
+ if (button == Qt::ExtraButton11) return 18;
+ if (button == Qt::ExtraButton12) return 19;
+ if (button == Qt::ExtraButton13) return 20;
+ if (button == Qt::ExtraButton14) return 21;
+ if (button == Qt::ExtraButton15) return 22;
+ if (button == Qt::ExtraButton16) return 23;
+ if (button == Qt::ExtraButton17) return 24;
+ if (button == Qt::ExtraButton18) return 25;
+ if (button == Qt::ExtraButton19) return 26;
+ if (button == Qt::ExtraButton20) return 27;
+ if (button == Qt::ExtraButton21) return 28;
+ if (button == Qt::ExtraButton22) return 29;
+ if (button == Qt::ExtraButton23) return 30;
+ if (button == Qt::ExtraButton24) return 31;
+ qDebug("QMouseShortcutEntry::addShortcut contained Invalid Qt::MouseButton value");
+ return 0;
+}
+
+QString ButtonTester::enumNameFromValue(const Qt::MouseButton button)
+{
+ if (button == Qt::NoButton) return "NoButton";
+ if (button == Qt::LeftButton) return "LeftButton";
+ if (button == Qt::RightButton) return "RightButton";
+ if (button == Qt::MiddleButton) return "MiddleButton";
+ if (button == Qt::BackButton) return "BackButton";
+ if (button == Qt::ForwardButton) return "ForwardButton";
+ if (button == Qt::TaskButton) return "TaskButton";
+ if (button == Qt::ExtraButton4) return "ExtraButton4";
+ if (button == Qt::ExtraButton5) return "ExtraButton5";
+ if (button == Qt::ExtraButton6) return "ExtraButton6";
+ if (button == Qt::ExtraButton7) return "ExtraButton7";
+ if (button == Qt::ExtraButton8) return "ExtraButton8";
+ if (button == Qt::ExtraButton9) return "ExtraButton9";
+ if (button == Qt::ExtraButton10) return "ExtraButton10";
+ if (button == Qt::ExtraButton11) return "ExtraButton11";
+ if (button == Qt::ExtraButton12) return "ExtraButton12";
+ if (button == Qt::ExtraButton13) return "ExtraButton13";
+ if (button == Qt::ExtraButton14) return "ExtraButton14";
+ if (button == Qt::ExtraButton15) return "ExtraButton15";
+ if (button == Qt::ExtraButton16) return "ExtraButton16";
+ if (button == Qt::ExtraButton17) return "ExtraButton17";
+ if (button == Qt::ExtraButton18) return "ExtraButton18";
+ if (button == Qt::ExtraButton19) return "ExtraButton19";
+ if (button == Qt::ExtraButton20) return "ExtraButton20";
+ if (button == Qt::ExtraButton21) return "ExtraButton21";
+ if (button == Qt::ExtraButton22) return "ExtraButton22";
+ if (button == Qt::ExtraButton23) return "ExtraButton23";
+ if (button == Qt::ExtraButton24) return "ExtraButton24";
+ qDebug("QMouseShortcutEntry::addShortcut contained Invalid Qt::MouseButton value");
+ return "NoButton";
+}
diff --git a/examples/widgets/mousebuttons/buttontester.h b/examples/widgets/mousebuttons/buttontester.h
new file mode 100644
index 0000000000..0801a9ae5c
--- /dev/null
+++ b/examples/widgets/mousebuttons/buttontester.h
@@ -0,0 +1,64 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Rick Stockton <rickstockton@reno-computerhelp.com>
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#ifndef BUTTONTESTER_H
+#define BUTTONTESTER_H
+
+#include <QtWidgets>
+#include <QTextEdit>
+#include <QString>
+#include <QDebug>
+#include <QMouseEvent>
+#include <QWheelEvent>
+
+class ButtonTester : public QTextEdit
+{
+ Q_OBJECT
+
+protected:
+ void mousePressEvent(QMouseEvent *event);
+ void mouseReleaseEvent(QMouseEvent *event);
+ void mouseDoubleClickEvent(QMouseEvent *event);
+ void wheelEvent(QWheelEvent * event);
+ int buttonByNumber(const Qt::MouseButton button);
+ QString enumNameFromValue(const Qt::MouseButton button);
+};
+
+#endif // BUTTONTESTER_H
diff --git a/examples/widgets/mousebuttons/main.cpp b/examples/widgets/mousebuttons/main.cpp
new file mode 100644
index 0000000000..7c9674a9d9
--- /dev/null
+++ b/examples/widgets/mousebuttons/main.cpp
@@ -0,0 +1,66 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Rick Stockton <rickstockton@reno-computerhelp.com>
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "buttontester.h"
+#include <QtGui>
+
+int main(int argv, char **args)
+{
+ QApplication app(argv, args);
+
+ ButtonTester *testArea = new ButtonTester;
+ testArea->setMinimumSize(500, 350);
+ testArea->setText("To test your mouse with Qt, press buttons in this area.\nYou may also scroll or tilt your mouse wheel.");
+ QPushButton *quitButton = new QPushButton("Quit");
+
+ QObject::connect(quitButton, SIGNAL(clicked()), qApp, SLOT(quit()));
+
+ QVBoxLayout *layout = new QVBoxLayout;
+ layout->addWidget(testArea);
+ layout->addWidget(quitButton);
+
+ QWidget window;
+ window.setLayout(layout);
+ window.setWindowTitle("Mouse Button Tester");
+ window.show();
+
+ return app.exec();
+}
diff --git a/examples/widgets/mousebuttons/mousebuttons.pro b/examples/widgets/mousebuttons/mousebuttons.pro
new file mode 100644
index 0000000000..823b04657e
--- /dev/null
+++ b/examples/widgets/mousebuttons/mousebuttons.pro
@@ -0,0 +1,18 @@
+TEMPLATE = app
+
+TARGET = buttontester
+TEMPLATE = app
+
+SOURCES += \
+ main.cpp\
+ buttontester.cpp \
+
+HEADERS += \
+ buttontester.h \
+
+# install
+target.path = $$[QT_INSTALL_EXAMPLES]/qtbase/examples/widgets/mousebuttons
+sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS buttontester.pro
+sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/examples/widgets/mousebuttons
+INSTALLS += target sources
+QT += core widgets
diff --git a/examples/widgets/widgets.pro b/examples/widgets/widgets.pro
index 51a92bcc29..f5c98c3c77 100644
--- a/examples/widgets/widgets.pro
+++ b/examples/widgets/widgets.pro
@@ -12,6 +12,7 @@ SUBDIRS = analogclock \
imageviewer \
lineedits \
movie \
+ mousebuttons \
orientation \
scribble \
shapedclock \