1 /**************************************************************************** |
|
2 ** |
|
3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). |
|
4 ** All rights reserved. |
|
5 ** Contact: Nokia Corporation (qt-info@nokia.com) |
|
6 ** |
|
7 ** This file is part of the Qt Mobility Components. |
|
8 ** |
|
9 ** $QT_BEGIN_LICENSE:BSD$ |
|
10 ** You may use this file under the terms of the BSD license as follows: |
|
11 ** |
|
12 ** "Redistribution and use in source and binary forms, with or without |
|
13 ** modification, are permitted provided that the following conditions are |
|
14 ** met: |
|
15 ** * Redistributions of source code must retain the above copyright |
|
16 ** notice, this list of conditions and the following disclaimer. |
|
17 ** * Redistributions in binary form must reproduce the above copyright |
|
18 ** notice, this list of conditions and the following disclaimer in |
|
19 ** the documentation and/or other materials provided with the |
|
20 ** distribution. |
|
21 ** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor |
|
22 ** the names of its contributors may be used to endorse or promote |
|
23 ** products derived from this software without specific prior written |
|
24 ** permission. |
|
25 ** |
|
26 ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
|
27 ** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
|
28 ** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
|
29 ** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
|
30 ** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
|
31 ** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
|
32 ** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
|
33 ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
|
34 ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
|
35 ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
|
36 ** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." |
|
37 ** $QT_END_LICENSE$ |
|
38 ** |
|
39 ****************************************************************************/ |
|
40 |
|
41 #include <qvaluespacesubscriber.h> |
|
42 |
|
43 #include <QApplication> |
|
44 #include <QObject> |
|
45 #include <QWidget> |
|
46 #include <QVBoxLayout> |
|
47 #include <QPushButton> |
|
48 #include <QUrl> |
|
49 #include <QDeclarativeView> |
|
50 #include <qdeclarative.h> |
|
51 #include <QtDeclarative> |
|
52 |
|
53 QTM_USE_NAMESPACE |
|
54 |
|
55 //! [0] |
|
56 QML_DECLARE_TYPE(QValueSpaceSubscriber); |
|
57 //! [0] |
|
58 |
|
59 class MainWidget : public QWidget |
|
60 { |
|
61 Q_OBJECT |
|
62 |
|
63 public: |
|
64 MainWidget(); |
|
65 |
|
66 private: |
|
67 QDeclarativeView *view; |
|
68 }; |
|
69 |
|
70 MainWidget::MainWidget() |
|
71 { |
|
72 QVBoxLayout *vbox = new QVBoxLayout; |
|
73 vbox->setMargin(0); |
|
74 setLayout(vbox); |
|
75 |
|
76 view = new QDeclarativeView(this); |
|
77 view->setFixedSize(100, 230); |
|
78 vbox->addWidget(view); |
|
79 |
|
80 //! [2] |
|
81 view->setSource(QUrl("qrc:/battery-meter.qml")); |
|
82 view->show(); |
|
83 //! [2] |
|
84 |
|
85 QPushButton *quitButton = new QPushButton("Quit"); |
|
86 vbox->addWidget(quitButton); |
|
87 connect(quitButton, SIGNAL(clicked()), qApp, SLOT(quit())); |
|
88 } |
|
89 |
|
90 int main(int argc, char *argv[]) |
|
91 { |
|
92 //! [1] |
|
93 qmlRegisterType<QValueSpaceSubscriber>("Qt", 4, 6, "ValueSpaceSubscriber"); |
|
94 //! [1] |
|
95 |
|
96 QApplication app(argc, argv); |
|
97 |
|
98 MainWidget mainWidget; |
|
99 mainWidget.show(); |
|
100 |
|
101 return app.exec(); |
|
102 } |
|
103 |
|
104 #include "main.moc" |
|