Qt 4.8
qt-4.8.6
src
plugins
platforms
uikit
examples
qmltest
main.mm
Go to the documentation of this file.
1
/****************************************************************************
2
**
3
** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
4
** Contact: http://www.qt-project.org/legal
5
**
6
** This file is part of the plugins of the Qt Toolkit.
7
**
8
** $QT_BEGIN_LICENSE:LGPL$
9
** Commercial License Usage
10
** Licensees holding valid commercial Qt licenses may use this file in
11
** accordance with the commercial license agreement provided with the
12
** Software or, alternatively, in accordance with the terms contained in
13
** a written agreement between you and Digia. For licensing terms and
14
** conditions see http://qt.digia.com/licensing. For further information
15
** use the contact form at http://qt.digia.com/contact-us.
16
**
17
** GNU Lesser General Public License Usage
18
** Alternatively, this file may be used under the terms of the GNU Lesser
19
** General Public License version 2.1 as published by the Free Software
20
** Foundation and appearing in the file LICENSE.LGPL included in the
21
** packaging of this file. Please review the following information to
22
** ensure the GNU Lesser General Public License version 2.1 requirements
23
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24
**
25
** In addition, as a special exception, Digia gives you certain additional
26
** rights. These rights are described in the Digia Qt LGPL Exception
27
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
28
**
29
** GNU General Public License Usage
30
** Alternatively, this file may be used under the terms of the GNU
31
** General Public License version 3.0 as published by the Free Software
32
** Foundation and appearing in the file LICENSE.GPL included in the
33
** packaging of this file. Please review the following information to
34
** ensure the GNU General Public License version 3.0 requirements will be
35
** met: http://www.gnu.org/copyleft/gpl.html.
36
**
37
**
38
** $QT_END_LICENSE$
39
**
40
****************************************************************************/
41
42
#import <UIKit/UIKit.h>
43
44
#include "../share/qmlapplicationviewer/qmlapplicationviewer.h"
45
46
#include <QtGui/QApplication>
47
#include <QtCore/QtPlugin>
48
#include <QtDeclarative/QDeclarativeEngine>
49
50
Q_IMPORT_PLUGIN
(UIKit)
51
52
static
QString
qStringFromNSString
(NSString *nsstring)
53
{
54
return
QString::fromUtf8
([nsstring UTF8String]);
55
}
56
57
static
QString
documentsDirectory
()
58
{
59
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
60
NSString *
documentsDirectory
= [paths objectAtIndex:0];
61
return
qStringFromNSString
(documentsDirectory);
62
}
63
64
int
main
(
int
argc,
char
*argv[]) {
65
66
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc]
init
];
67
68
QApplication
app(argc, argv);
69
QmlApplicationViewer
viewer;
70
viewer.
setOrientation
(
QmlApplicationViewer::ScreenOrientationAuto
);
71
viewer.
engine
()->
setOfflineStoragePath
(
documentsDirectory
());
72
NSString *resourcePath = [[NSBundle mainBundle] resourcePath];
73
viewer.
setMainQmlFile
(
qStringFromNSString
([resourcePath stringByAppendingPathComponent:
@"qml/main.qml"
]));
74
viewer.
showMaximized
();
75
int
retVal = app.
exec
();
76
[pool release];
77
return
retVal;
78
}
Q_IMPORT_PLUGIN
#define Q_IMPORT_PLUGIN(PLUGIN)
Definition:
qplugin.h:66
QWidget::showMaximized
void showMaximized()
Shows the widget maximized.
Definition:
qwidget.cpp:3218
QApplication
The QApplication class manages the GUI application's control flow and main settings.
Definition:
qapplication.h:99
QApplication::exec
static int exec()
Enters the main event loop and waits until exit() is called, then returns the value that was set to e...
Definition:
qapplication.cpp:3916
QDeclarativeEngine::setOfflineStoragePath
void setOfflineStoragePath(const QString &dir)
Definition:
qdeclarativeengine.cpp:2325
QString
The QString class provides a Unicode character string.
Definition:
qstring.h:83
QmlApplicationViewer::ScreenOrientationAuto
Definition:
qmlapplicationviewer.h:65
QmlApplicationViewer::setOrientation
void setOrientation(ScreenOrientation orientation)
Definition:
qmlapplicationviewer.cpp:146
init
static bool init
Definition:
qclipboard_qws.cpp:67
QString::fromUtf8
static QString fromUtf8(const char *, int size=-1)
Returns a QString initialized with the first size bytes of the UTF-8 string str.
Definition:
qstring.cpp:4302
QmlApplicationViewer::setMainQmlFile
void setMainQmlFile(const QString &file)
Definition:
qmlapplicationviewer.cpp:135
QmlApplicationViewer
Definition:
qmlapplicationviewer.h:57
main
int main(int argc, char *argv[])
Definition:
main.mm:64
QDeclarativeView::engine
QDeclarativeEngine * engine() const
Returns a pointer to the QDeclarativeEngine used for instantiating QML Components.
Definition:
qdeclarativeview.cpp:369
qStringFromNSString
static QString qStringFromNSString(NSString *nsstring)
Definition:
main.mm:52
documentsDirectory
static QString documentsDirectory()
Definition:
main.mm:57
Qt 4.8 Source Code Browser