summaryrefslogtreecommitdiffstats
path: root/examples/widgets/widgets/orientation
diff options
context:
space:
mode:
authorGabriel de Dietrich <gabriel.dietrich-de@nokia.com>2012-08-17 13:23:19 +0200
committerQt by Nokia <qt-info@nokia.com>2012-08-20 12:20:55 +0200
commit806dda08d685bc5f9ed71dfe8b61f21848d48066 (patch)
treea63533a1c4a335ae17adc105abb0ae4e62e2f26e /examples/widgets/widgets/orientation
parent9f942014e31842b512c3198de035d041c59f54a9 (diff)
Moving .qdoc files under examples/widgets/doc
Updated those .qdoc files to refer to the new relative examples emplacement. Images and snippets to be moved later. Also grouped all widgets related examples under widgets. Change-Id: Ib29696e2d8948524537f53e8dda88f9ee26a597f Reviewed-by: J-P Nurmi <j-p.nurmi@nokia.com>
Diffstat (limited to 'examples/widgets/widgets/orientation')
-rw-r--r--examples/widgets/widgets/orientation/image_a.pngbin0 -> 1075 bytes
-rw-r--r--examples/widgets/widgets/orientation/image_b.pngbin0 -> 1020 bytes
-rw-r--r--examples/widgets/widgets/orientation/image_c.pngbin0 -> 1163 bytes
-rw-r--r--examples/widgets/widgets/orientation/images.qrc7
-rw-r--r--examples/widgets/widgets/orientation/landscape.ui114
-rw-r--r--examples/widgets/widgets/orientation/main.cpp55
-rw-r--r--examples/widgets/widgets/orientation/mainwindow.cpp112
-rw-r--r--examples/widgets/widgets/orientation/mainwindow.h75
-rw-r--r--examples/widgets/widgets/orientation/orientation.desktop11
-rw-r--r--examples/widgets/widgets/orientation/orientation.pro31
-rw-r--r--examples/widgets/widgets/orientation/portrait.ui61
11 files changed, 466 insertions, 0 deletions
diff --git a/examples/widgets/widgets/orientation/image_a.png b/examples/widgets/widgets/orientation/image_a.png
new file mode 100644
index 0000000000..4a1a0d3252
--- /dev/null
+++ b/examples/widgets/widgets/orientation/image_a.png
Binary files differ
diff --git a/examples/widgets/widgets/orientation/image_b.png b/examples/widgets/widgets/orientation/image_b.png
new file mode 100644
index 0000000000..8722d1edee
--- /dev/null
+++ b/examples/widgets/widgets/orientation/image_b.png
Binary files differ
diff --git a/examples/widgets/widgets/orientation/image_c.png b/examples/widgets/widgets/orientation/image_c.png
new file mode 100644
index 0000000000..6c9304fda0
--- /dev/null
+++ b/examples/widgets/widgets/orientation/image_c.png
Binary files differ
diff --git a/examples/widgets/widgets/orientation/images.qrc b/examples/widgets/widgets/orientation/images.qrc
new file mode 100644
index 0000000000..b258291e6f
--- /dev/null
+++ b/examples/widgets/widgets/orientation/images.qrc
@@ -0,0 +1,7 @@
+<RCC>
+ <qresource prefix="/">
+ <file>image_a.png</file>
+ <file>image_b.png</file>
+ <file>image_c.png</file>
+ </qresource>
+</RCC>
diff --git a/examples/widgets/widgets/orientation/landscape.ui b/examples/widgets/widgets/orientation/landscape.ui
new file mode 100644
index 0000000000..4616c041dc
--- /dev/null
+++ b/examples/widgets/widgets/orientation/landscape.ui
@@ -0,0 +1,114 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>LandscapeUI</class>
+ <widget class="QWidget" name="LandscapeUI">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>514</width>
+ <height>265</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>Form</string>
+ </property>
+ <layout class="QGridLayout" name="gridLayout">
+ <item row="0" column="0" colspan="2">
+ <widget class="QLabel" name="label">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Expanding" vsizetype="Preferred">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="styleSheet">
+ <string notr="true">font-weight: bold;</string>
+ </property>
+ <property name="text">
+ <string>Landscape mode</string>
+ </property>
+ <property name="alignment">
+ <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="2">
+ <widget class="QPushButton" name="exitButton">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Minimum" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>Exit</string>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="2">
+ <widget class="QGroupBox" name="groupBox">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Preferred" vsizetype="Expanding">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="title">
+ <string>Choices</string>
+ </property>
+ <layout class="QVBoxLayout" name="verticalLayout">
+ <item>
+ <widget class="QRadioButton" name="radioAButton">
+ <property name="text">
+ <string>Long description explaining choice A</string>
+ </property>
+ <property name="checked">
+ <bool>true</bool>
+ </property>
+ <attribute name="buttonGroup">
+ <string>buttonGroup</string>
+ </attribute>
+ </widget>
+ </item>
+ <item>
+ <widget class="QRadioButton" name="radioBButton">
+ <property name="text">
+ <string>Long description explaining choice B</string>
+ </property>
+ <attribute name="buttonGroup">
+ <string>buttonGroup</string>
+ </attribute>
+ </widget>
+ </item>
+ <item>
+ <widget class="QRadioButton" name="radioCButton">
+ <property name="text">
+ <string>Long description explaining choice C</string>
+ </property>
+ <attribute name="buttonGroup">
+ <string>buttonGroup</string>
+ </attribute>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ <item row="1" column="0" colspan="2">
+ <widget class="QWidget" name="choiceWidget" native="true">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Expanding" vsizetype="Expanding">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ <resources/>
+ <connections/>
+ <buttongroups>
+ <buttongroup name="buttonGroup"/>
+ </buttongroups>
+</ui>
diff --git a/examples/widgets/widgets/orientation/main.cpp b/examples/widgets/widgets/orientation/main.cpp
new file mode 100644
index 0000000000..d92ae0c16f
--- /dev/null
+++ b/examples/widgets/widgets/orientation/main.cpp
@@ -0,0 +1,55 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtCore module 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 <QtWidgets/QApplication>
+#include "mainwindow.h"
+
+//! [0]
+int main(int argc, char *argv[])
+{
+ QApplication a(argc, argv);
+
+ MainWindow w;
+ w.showFullScreen();
+
+ return a.exec();
+}
+//! [0]
+
diff --git a/examples/widgets/widgets/orientation/mainwindow.cpp b/examples/widgets/widgets/orientation/mainwindow.cpp
new file mode 100644
index 0000000000..3acbef12f8
--- /dev/null
+++ b/examples/widgets/widgets/orientation/mainwindow.cpp
@@ -0,0 +1,112 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtCore module 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 "mainwindow.h"
+#include "ui_landscape.h"
+#include "ui_portrait.h"
+
+#include <QDesktopWidget>
+#include <QResizeEvent>
+
+//! [0]
+MainWindow::MainWindow(QWidget *parent) :
+ QWidget(parent),
+ landscapeWidget(0),
+ portraitWidget(0)
+{
+ landscapeWidget = new QWidget(this);
+ landscape.setupUi(landscapeWidget);
+
+ portraitWidget = new QWidget(this);
+ portrait.setupUi(portraitWidget);
+//! [0]
+
+//! [1]
+ connect(portrait.exitButton, SIGNAL(clicked()), this, SLOT(close()));
+ connect(landscape.exitButton, SIGNAL(clicked()), this, SLOT(close()));
+ connect(landscape.buttonGroup, SIGNAL(buttonClicked(QAbstractButton*)),
+ this, SLOT(onRadioButtonClicked(QAbstractButton*)));
+
+ landscape.radioAButton->setChecked(true);
+ onRadioButtonClicked(landscape.radioAButton);
+//! [1]
+
+//! [2]
+}
+//! [2]
+
+//! [3]
+void MainWindow::resizeEvent(QResizeEvent *event)
+{
+ QSize size = event->size();
+ bool isLandscape = size.width() > size.height();
+
+ if (!isLandscape)
+ size.transpose();
+
+ landscapeWidget->setFixedSize(size);
+ size.transpose();
+ portraitWidget->setFixedSize(size);
+
+ landscapeWidget->setVisible(isLandscape);
+ portraitWidget->setVisible(!isLandscape);
+}
+//! [3]
+
+//! [4]
+void MainWindow::onRadioButtonClicked(QAbstractButton *button)
+{
+ QString styleTemplate = "background-image: url(:/image_%1.png);"
+ "background-repeat: no-repeat;"
+ "background-position: center center";
+
+ QString imageStyle("");
+ if (button == landscape.radioAButton)
+ imageStyle = styleTemplate.arg("a");
+ else if (button == landscape.radioBButton)
+ imageStyle = styleTemplate.arg("b");
+ else if (button == landscape.radioCButton)
+ imageStyle = styleTemplate.arg("c");
+
+ portrait.choiceWidget->setStyleSheet(imageStyle);
+ landscape.choiceWidget->setStyleSheet(imageStyle);
+}
+//! [4]
+
diff --git a/examples/widgets/widgets/orientation/mainwindow.h b/examples/widgets/widgets/orientation/mainwindow.h
new file mode 100644
index 0000000000..d0f1b07242
--- /dev/null
+++ b/examples/widgets/widgets/orientation/mainwindow.h
@@ -0,0 +1,75 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtCore module 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 MAINWINDOW_H
+#define MAINWINDOW_H
+
+#include <QWidget>
+
+#include "ui_landscape.h"
+#include "ui_portrait.h"
+
+QT_BEGIN_NAMESPACE
+class QAbstractButton;
+QT_END_NAMESPACE
+
+//! [0]
+class MainWindow : public QWidget
+{
+ Q_OBJECT
+
+public:
+ MainWindow(QWidget *parent = 0);
+
+protected:
+ void resizeEvent(QResizeEvent *event);
+
+private slots:
+ void onRadioButtonClicked(QAbstractButton *button);
+
+private:
+ Ui::LandscapeUI landscape;
+ Ui::PortraitUI portrait;
+ QWidget *landscapeWidget;
+ QWidget *portraitWidget;
+};
+//! [0]
+
+#endif // MAINWINDOW_H
diff --git a/examples/widgets/widgets/orientation/orientation.desktop b/examples/widgets/widgets/orientation/orientation.desktop
new file mode 100644
index 0000000000..7bbf5584d3
--- /dev/null
+++ b/examples/widgets/widgets/orientation/orientation.desktop
@@ -0,0 +1,11 @@
+[Desktop Entry]
+Encoding=UTF-8
+Version=1.0
+Type=Application
+Terminal=false
+Name=Orientation
+Exec=/opt/usr/bin/orientation
+Icon=orientation
+X-Window-Icon=
+X-HildonDesk-ShowInToolbar=true
+X-Osso-Type=application/x-executable
diff --git a/examples/widgets/widgets/orientation/orientation.pro b/examples/widgets/widgets/orientation/orientation.pro
new file mode 100644
index 0000000000..36a3e91a9c
--- /dev/null
+++ b/examples/widgets/widgets/orientation/orientation.pro
@@ -0,0 +1,31 @@
+#-------------------------------------------------
+#
+# Project created by QtCreator 2010-08-04T10:27:31
+#
+#-------------------------------------------------
+
+QT += core gui widgets
+
+TARGET = orientation
+TEMPLATE = app
+
+
+SOURCES += main.cpp\
+ mainwindow.cpp
+
+HEADERS += mainwindow.h
+
+FORMS += \
+ portrait.ui \
+ landscape.ui
+
+RESOURCES += \
+ images.qrc
+
+# install
+target.path = $$[QT_INSTALL_EXAMPLES]/qtbase/widgets/orientation
+sources.files = $$SOURCES $$HEADERS $$FORMS $$RESOURCES *.png *.pro
+sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/widgets/orientation
+INSTALLS += target sources
+
+simulator: warning(This example might not fully work on Simulator platform)
diff --git a/examples/widgets/widgets/orientation/portrait.ui b/examples/widgets/widgets/orientation/portrait.ui
new file mode 100644
index 0000000000..31a55aff73
--- /dev/null
+++ b/examples/widgets/widgets/orientation/portrait.ui
@@ -0,0 +1,61 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>PortraitUI</class>
+ <widget class="QWidget" name="PortraitUI">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>201</width>
+ <height>300</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>Form</string>
+ </property>
+ <layout class="QGridLayout" name="gridLayout">
+ <item row="0" column="0">
+ <widget class="QLabel" name="label">
+ <property name="styleSheet">
+ <string notr="true">font-weight: bold;</string>
+ </property>
+ <property name="text">
+ <string>Portrait mode</string>
+ </property>
+ <property name="alignment">
+ <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
+ </property>
+ </widget>
+ </item>
+ <item row="3" column="0">
+ <widget class="QPushButton" name="exitButton">
+ <property name="text">
+ <string>Exit</string>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="0">
+ <widget class="QLabel" name="helpLabel">
+ <property name="text">
+ <string>Switch to landscape mode. In landscape mode you can change visible image.</string>
+ </property>
+ <property name="wordWrap">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="0">
+ <widget class="QWidget" name="choiceWidget" native="true">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Preferred" vsizetype="Expanding">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>