Doc: Remove applicationicon and orientation examples from QtWidgets
These two widget-based, mobile-targeted examples are obsolete, defunct, and/or serve no purpose in Qt 5. Task-number: QTBUG-31023 Change-Id: Ie5732734bb2547b1ea701d7b3c8dcd806362de09 Reviewed-by: Jerome Pasion <jerome.pasion@digia.com>
Before Width: | Height: | Size: 21 KiB |
Before Width: | Height: | Size: 147 KiB |
Before Width: | Height: | Size: 18 KiB |
Before Width: | Height: | Size: 45 KiB |
Before Width: | Height: | Size: 9.6 KiB |
Before Width: | Height: | Size: 17 KiB |
@ -1,142 +0,0 @@
|
|||||||
/****************************************************************************
|
|
||||||
**
|
|
||||||
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
|
|
||||||
** Contact: http://www.qt-project.org/legal
|
|
||||||
**
|
|
||||||
** This file is part of the documentation of the Qt Toolkit.
|
|
||||||
**
|
|
||||||
** $QT_BEGIN_LICENSE:FDL$
|
|
||||||
** Commercial License Usage
|
|
||||||
** Licensees holding valid commercial Qt licenses may use this file in
|
|
||||||
** accordance with the commercial license agreement provided with the
|
|
||||||
** Software or, alternatively, in accordance with the terms contained in
|
|
||||||
** a written agreement between you and Digia. For licensing terms and
|
|
||||||
** conditions see http://qt.digia.com/licensing. For further information
|
|
||||||
** use the contact form at http://qt.digia.com/contact-us.
|
|
||||||
**
|
|
||||||
** GNU Free Documentation License Usage
|
|
||||||
** Alternatively, this file may be used under the terms of the GNU Free
|
|
||||||
** Documentation License version 1.3 as published by the Free Software
|
|
||||||
** Foundation and appearing in the file included in the packaging of
|
|
||||||
** this file. Please review the following information to ensure
|
|
||||||
** the GNU Free Documentation License version 1.3 requirements
|
|
||||||
** will be met: http://www.gnu.org/copyleft/fdl.html.
|
|
||||||
** $QT_END_LICENSE$
|
|
||||||
**
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
/*! \example widgets/orientation
|
|
||||||
\title Orientation Example
|
|
||||||
|
|
||||||
\brief The example shows a simple way to use different UIs depending on the screen
|
|
||||||
orientation of a mobile device.
|
|
||||||
|
|
||||||
\image orientation-landscape.png The UI in landscape mode
|
|
||||||
\image orientation-portrait.png The UI in portrait mode
|
|
||||||
|
|
||||||
The screen on many mobile devices can be viewed in both portrait and
|
|
||||||
landscape orientation. The orientation can be swiched with the help of a
|
|
||||||
hardware or software trigger. Due to the often small physical screen size,
|
|
||||||
user interfaces has to be very simple and compact to stay usable, and
|
|
||||||
applications usually occupy the whole screen. Designing a user interface
|
|
||||||
that works equally well in both landscape and portrait mode is not always
|
|
||||||
possible, however, so making a different layout for each case usually pays
|
|
||||||
off.
|
|
||||||
|
|
||||||
The example application makes use of two different UI widgets created with
|
|
||||||
the Qt Designer, one for portrait and one for landscape orientation. The
|
|
||||||
application has a widget that contains an image and the user is able to
|
|
||||||
select one of three images for it to show. In addition to the two UIs, the
|
|
||||||
application consists of a \c MainWindow class.
|
|
||||||
|
|
||||||
\section1 Landscape UI
|
|
||||||
|
|
||||||
If the screen is in landscape mode, the user probably holds the device with
|
|
||||||
both hands and is ready to give full attention to the application. The
|
|
||||||
landscape UI looks like this:
|
|
||||||
|
|
||||||
\image orientation-landscape-ui.png The landscape UI
|
|
||||||
|
|
||||||
To the left is a QWidget called \c choiceWidget, which will show the
|
|
||||||
current image, and to the right are three QRadioButton instances. The
|
|
||||||
active radio button specifies the image to show.
|
|
||||||
|
|
||||||
\section1 Portrait UI
|
|
||||||
|
|
||||||
When the device is in portrait mode, it usually means that the user holds
|
|
||||||
it with one hand, and can comfortably use the thumb for small amounts of
|
|
||||||
input. The layout is simpler, and is focused on consuming content. The
|
|
||||||
portrait UI looks like this:
|
|
||||||
|
|
||||||
\image orientation-portrait-ui.png The portrait UI
|
|
||||||
|
|
||||||
Similarly, it contains a QWidget, also called \c choiceWidget, that will
|
|
||||||
show the current image. In contrast to the landscape UI, this one doesn't
|
|
||||||
provide any controls to change the image.
|
|
||||||
|
|
||||||
\section1 MainWindow Class Definition
|
|
||||||
|
|
||||||
\c MainWindow inherits from QWidget and acts as the top level widget of the
|
|
||||||
application.
|
|
||||||
|
|
||||||
\snippet widgets/orientation/mainwindow.h 0
|
|
||||||
|
|
||||||
The \c resizeEvent() method is re-implemented, and used to check which
|
|
||||||
UI to show. The \c onRadioButtonClicked() slot is connected to the
|
|
||||||
landscape UI's radio button group and selects the current image.
|
|
||||||
|
|
||||||
\c landscapeWidget and \c portraitWidget will contain the UI layouts. Only
|
|
||||||
one of them is visible at a time.
|
|
||||||
|
|
||||||
\section1 MainWindow Class Implementation
|
|
||||||
|
|
||||||
In the constructor, the widgets that will hold the UIs are created and set
|
|
||||||
up.
|
|
||||||
|
|
||||||
\snippet widgets/orientation/mainwindow.cpp 0
|
|
||||||
|
|
||||||
Since the exit buttons on the layouts are different from each other, both
|
|
||||||
of them have to have their \c clicked() signal connected to the \c close()
|
|
||||||
slot of the main widget. The first image is also made current with the call
|
|
||||||
to \c onRadioButtonClicked().
|
|
||||||
|
|
||||||
\snippet widgets/orientation/mainwindow.cpp 1
|
|
||||||
|
|
||||||
On the Maemo platform, windows are stuck in landscape mode by default. The
|
|
||||||
application has to explicitly say that rotation is supported.
|
|
||||||
|
|
||||||
\snippet widgets/orientation/mainwindow.cpp 2
|
|
||||||
|
|
||||||
The \c resizeEvent() is called when the main window is first created, and
|
|
||||||
also whenever the window has been resized. If the window is shown in
|
|
||||||
full screen, this is an indication that the orientation of the screen has
|
|
||||||
changed.
|
|
||||||
|
|
||||||
The dimensions of \c landscapeWidget is the transpose of the dimensions of
|
|
||||||
\c portraitWidget. When the orientation is known, both are set to the
|
|
||||||
(possibly transposed) size of the window. Depending on the orientation, one
|
|
||||||
widget is made visible and the other invisible.
|
|
||||||
|
|
||||||
\snippet widgets/orientation/mainwindow.cpp 3
|
|
||||||
|
|
||||||
When the user selects one of the radio buttons in the landscape UI, the
|
|
||||||
current image is changed. The image is displayed by specifying the
|
|
||||||
background style of the choice widget. Since both \c portrait and
|
|
||||||
\c landscape have a \c choiceWidget of their own, the change has to be
|
|
||||||
reflected in both instances.
|
|
||||||
|
|
||||||
\snippet widgets/orientation/mainwindow.cpp 4
|
|
||||||
|
|
||||||
Synchronizing both UIs like this might become unfeasible when there are
|
|
||||||
many things that can change. In that case it is better to make use of the
|
|
||||||
\l{Introduction to Model/View Programming}{Model-View-Controller pattern}
|
|
||||||
more extensively and share the content between both portrait and landscape
|
|
||||||
widgets. Then an interface for displaying and manipulating it can be tailor
|
|
||||||
made for both orientations.
|
|
||||||
|
|
||||||
\section1 The \c main() Function
|
|
||||||
|
|
||||||
The main function creates a \c MainWindow instance and shows it full
|
|
||||||
screen.
|
|
||||||
\snippet widgets/orientation/main.cpp 0
|
|
||||||
*/
|
|
@ -1,52 +0,0 @@
|
|||||||
/****************************************************************************
|
|
||||||
**
|
|
||||||
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
|
|
||||||
** Contact: http://www.qt-project.org/legal
|
|
||||||
**
|
|
||||||
** This file is part of the documentation of the Qt Toolkit.
|
|
||||||
**
|
|
||||||
** $QT_BEGIN_LICENSE:FDL$
|
|
||||||
** Commercial License Usage
|
|
||||||
** Licensees holding valid commercial Qt licenses may use this file in
|
|
||||||
** accordance with the commercial license agreement provided with the
|
|
||||||
** Software or, alternatively, in accordance with the terms contained in
|
|
||||||
** a written agreement between you and Digia. For licensing terms and
|
|
||||||
** conditions see http://qt.digia.com/licensing. For further information
|
|
||||||
** use the contact form at http://qt.digia.com/contact-us.
|
|
||||||
**
|
|
||||||
** GNU Free Documentation License Usage
|
|
||||||
** Alternatively, this file may be used under the terms of the GNU Free
|
|
||||||
** Documentation License version 1.3 as published by the Free Software
|
|
||||||
** Foundation and appearing in the file included in the packaging of
|
|
||||||
** this file. Please review the following information to ensure
|
|
||||||
** the GNU Free Documentation License version 1.3 requirements
|
|
||||||
** will be met: http://www.gnu.org/copyleft/fdl.html.
|
|
||||||
** $QT_END_LICENSE$
|
|
||||||
**
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
/*! \example widgets/applicationicon
|
|
||||||
\title Application Icon Example
|
|
||||||
|
|
||||||
\brief The example shows how to add an application icon to a mobile application.
|
|
||||||
|
|
||||||
\image appicon_screenshot.png The icon on a Nokia XPressMusic 5800
|
|
||||||
|
|
||||||
\section1 Adding the icons to the project
|
|
||||||
|
|
||||||
For Maemo, we need to add that the \c .desktop and icon file should be
|
|
||||||
installed.
|
|
||||||
|
|
||||||
\quotefile widgets/applicationicon/applicationicon.pro
|
|
||||||
|
|
||||||
Currently, Qt Creator doesn't include the icon and desktop files in the
|
|
||||||
application package for Maemo, merely the executable file is included. As a
|
|
||||||
workaround for this, the files can be added manually in the Projects tab.
|
|
||||||
In the "Create Package" build step for the Maemo target, the \c .desktop
|
|
||||||
file and icon can be added to be a part of the package contents.
|
|
||||||
Unfortunately, these additions are only stored as a part of the
|
|
||||||
\c .pro.user file. This issue will be resolved in a future release of
|
|
||||||
Qt Creator.
|
|
||||||
|
|
||||||
\image appicon_packagecontents.png Manual addition of files to the "Create Package" build step
|
|
||||||
*/
|
|
Before Width: | Height: | Size: 3.9 KiB |
@ -1,15 +0,0 @@
|
|||||||
|
|
||||||
QT += core gui widgets
|
|
||||||
|
|
||||||
TARGET = applicationicon
|
|
||||||
TEMPLATE = app
|
|
||||||
|
|
||||||
SOURCES += main.cpp
|
|
||||||
|
|
||||||
OTHER_FILES += applicationicon.svg \
|
|
||||||
applicationicon.png \
|
|
||||||
applicationicon.desktop
|
|
||||||
|
|
||||||
# install
|
|
||||||
target.path = $$[QT_INSTALL_EXAMPLES]/widgets/widgets/applicationicon
|
|
||||||
INSTALLS += target
|
|
@ -1,22 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
|
||||||
<svg xmlns="http://www.w3.org/2000/svg" width="44" height="44" baseProfile="tiny" version="1.1" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 44 44">
|
|
||||||
<defs>
|
|
||||||
<linearGradient id="linearGradient2824" y2="1051.4" gradientUnits="userSpaceOnUse" x2="30.217" y1="1009.4" x1="15.109">
|
|
||||||
<stop stop-color="#41a200" offset="0"/>
|
|
||||||
<stop stop-color="#9be948" offset="0.63897"/>
|
|
||||||
<stop stop-color="#beff61" offset="1"/>
|
|
||||||
</linearGradient>
|
|
||||||
<linearGradient id="linearGradient2848" y2="1009.4" gradientUnits="userSpaceOnUse" y1="1053.7" gradientTransform="matrix(0.85714286,0,0,0.85714286,2.1428572,146.19467)" x2="15.085" x1="31.027">
|
|
||||||
<stop stop-color="#41a200" offset="0"/>
|
|
||||||
<stop stop-color="#9be948" offset="0.88602"/>
|
|
||||||
<stop stop-color="#beff61" offset="1"/>
|
|
||||||
</linearGradient>
|
|
||||||
</defs>
|
|
||||||
<g id="layer1" transform="translate(0,-1008.3622)">
|
|
||||||
<path id="rect2816" d="m8.412,1009h27.18c4.106,0,7.412,3.306,7.412,7.412v27.18c0,4.106-3.306,7.412-7.412,7.412h-27.18c-4.106,0-7.412-3-7.412-7v-27.18c0-4.106,3.306-7.412,7.412-7.412z" stroke-linecap="round" stroke-miterlimit="4" stroke-width="0.64300001" fill="url(#linearGradient2824)"/>
|
|
||||||
<path id="rect2816-4" d="m9.353,1011h25.29c3.52,0,6.353,2.833,6.353,6.353v25.29c0,3.519-2.833,6.353-6.353,6.353h-25.29c-3.52-0.1-6.353-2.1-6.353-6.1v-25.29c0-3.519,2.833-6.353,6.353-6.353z" stroke-linecap="round" stroke-miterlimit="4" stroke-width="0.64300001" fill="url(#linearGradient2848)"/>
|
|
||||||
<g id="text2893" font-weight="normal" transform="translate(-1.100281,1010.3622)" font-style="normal" font-stretch="normal" font-size="48px" font-variant="normal" font-family="Cambria Math" fill="#e5ffd5">
|
|
||||||
<path id="path2908" fill="#e5ffd5" d="m11.92,35.44c1.359-1.719,2.672-3.828,3.938-6.328l7.522-14.742c-0.8-3.13-1.54-5.321-2.24-6.586-0.69-1.266-1.76-1.899-3.2-1.899-1.328,0.0000307-2.594,0.6563-3.797,1.969l-1.148-1.266c2.156-2.359,4.289-3.539,6.398-3.539,1.469,0.0000335,2.609,0.418,3.422,1.254,0.8125,0.836,1.492,2.168,2.039,3.996,0.5469,1.828,1.32,5.359,2.32,10.59,1.297,6.828,2.309,11.14,3.035,12.93,0.7265,1.789,1.59,2.684,2.59,2.684,0.7187,0.000002,1.383-0.25,1.992-0.75l0.8906,1.406c-1.547,1.203-2.938,1.805-4.172,1.805-1.75,0-3-0.8984-3.75-2.695-0.75-1.797-1.797-6.633-3.141-14.51h-0.1406c-2.658,5.391-5.258,11.001-7.798,16.831h-4.758z"/>
|
|
||||||
</g>
|
|
||||||
</g>
|
|
||||||
</svg>
|
|
Before Width: | Height: | Size: 2.3 KiB |
@ -1,50 +0,0 @@
|
|||||||
/****************************************************************************
|
|
||||||
**
|
|
||||||
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
|
|
||||||
** Contact: http://www.qt-project.org/legal
|
|
||||||
**
|
|
||||||
** 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 Digia Plc 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 <QtWidgets/QLabel>
|
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
|
||||||
{
|
|
||||||
QApplication a(argc, argv);
|
|
||||||
QLabel label(QObject::tr("Hello, world!"));
|
|
||||||
label.show();
|
|
||||||
return a.exec();
|
|
||||||
}
|
|
Before Width: | Height: | Size: 1.0 KiB |
Before Width: | Height: | Size: 1020 B |
Before Width: | Height: | Size: 1.1 KiB |
@ -1,7 +0,0 @@
|
|||||||
<RCC>
|
|
||||||
<qresource prefix="/">
|
|
||||||
<file>image_a.png</file>
|
|
||||||
<file>image_b.png</file>
|
|
||||||
<file>image_c.png</file>
|
|
||||||
</qresource>
|
|
||||||
</RCC>
|
|
@ -1,114 +0,0 @@
|
|||||||
<?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>
|
|
@ -1,55 +0,0 @@
|
|||||||
/****************************************************************************
|
|
||||||
**
|
|
||||||
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
|
|
||||||
** Contact: http://www.qt-project.org/legal
|
|
||||||
**
|
|
||||||
** 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 Digia Plc 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]
|
|
||||||
|
|
@ -1,112 +0,0 @@
|
|||||||
/****************************************************************************
|
|
||||||
**
|
|
||||||
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
|
|
||||||
** Contact: http://www.qt-project.org/legal
|
|
||||||
**
|
|
||||||
** 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 Digia Plc 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]
|
|
||||||
|
|
@ -1,75 +0,0 @@
|
|||||||
/****************************************************************************
|
|
||||||
**
|
|
||||||
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
|
|
||||||
** Contact: http://www.qt-project.org/legal
|
|
||||||
**
|
|
||||||
** 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 Digia Plc 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
|
|
@ -1,29 +0,0 @@
|
|||||||
#-------------------------------------------------
|
|
||||||
#
|
|
||||||
# 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]/widgets/widgets/orientation
|
|
||||||
INSTALLS += target
|
|
||||||
|
|
||||||
simulator: warning(This example might not fully work on Simulator platform)
|
|
@ -1,61 +0,0 @@
|
|||||||
<?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>
|
|
@ -1,6 +1,5 @@
|
|||||||
TEMPLATE = subdirs
|
TEMPLATE = subdirs
|
||||||
SUBDIRS = analogclock \
|
SUBDIRS = analogclock \
|
||||||
applicationicon \
|
|
||||||
calculator \
|
calculator \
|
||||||
calendarwidget \
|
calendarwidget \
|
||||||
charactermap \
|
charactermap \
|
||||||
@ -13,7 +12,6 @@ SUBDIRS = analogclock \
|
|||||||
lineedits \
|
lineedits \
|
||||||
movie \
|
movie \
|
||||||
mousebuttons \
|
mousebuttons \
|
||||||
orientation \
|
|
||||||
scribble \
|
scribble \
|
||||||
shapedclock \
|
shapedclock \
|
||||||
sliders \
|
sliders \
|
||||||
|