39 ** |
39 ** |
40 ****************************************************************************/ |
40 ****************************************************************************/ |
41 |
41 |
42 #include <QApplication> |
42 #include <QApplication> |
43 #include <QtGui> |
43 #include <QtGui> |
44 #include <QmlEngine> |
44 #include <QDeclarativeEngine> |
45 #include <QmlComponent> |
45 #include <QDeclarativeComponent> |
46 #include <QDebug> |
46 #include <QDebug> |
47 #include <QmlGraphicsItem> |
47 #include <QDeclarativeView> |
48 #include <QmlView> |
|
49 #include <QContactManager> |
48 #include <QContactManager> |
50 #include "qmlcontactsa.h" |
49 #include "qmlcontactsa.h" |
|
50 #include "qmlcontact.h" |
51 QT_USE_NAMESPACE |
51 QT_USE_NAMESPACE |
52 QTM_USE_NAMESPACE |
52 QTM_USE_NAMESPACE |
53 |
53 |
54 int main(int argc, char ** argv) |
54 int main(int argc, char ** argv) |
55 { |
55 { |
56 QApplication app(argc, argv); |
56 QApplication app(argc, argv); |
57 |
57 |
58 |
58 |
59 QmlEngine engine; |
59 QDeclarativeEngine engine; |
60 QmlComponent component(&engine, ":example.qml"); |
60 QDeclarativeComponent component(&engine, ":example.qml"); |
61 // QMLContactManager *qcm = qobject_cast<QMLContactManager *>(component.create()); |
|
62 // if (qcm) { |
|
63 // qWarning() << "Available back ends: " << qcm->availableManagers(); |
|
64 // qWarning() << "Current Backend: " << qcm->manager(); |
|
65 // //qWarning() << "They wear a" << person->shoeSize() << "sized shoe"; |
|
66 // } else { |
|
67 // |
|
68 // qWarning() << "An error occured"; |
|
69 // qWarning() << component.errorsString(); |
|
70 // exit(-1); |
|
71 // } |
|
72 // QmlGraphicsItem *qcm = qobject_cast<QmlGraphicsItem *>(component.create()); |
|
73 // if(!qcm){ |
|
74 // qWarning() << "An error occured"; |
|
75 // qWarning() << component.errorsString(); |
|
76 // exit(-1); |
|
77 // |
|
78 // } |
|
79 // qcm->show(); |
|
80 |
61 |
81 QWidget *b = new QWidget; |
62 qmlRegisterType<QmlContact>("QmlContact", 1, 0, "QmlContact"); |
|
63 qmlRegisterType<QMLContactManagerAsync>("QMLContactManagerAsync", 1, 0, "QMLContactManagerAsync"); |
|
64 |
|
65 QWidget *b = new QWidget(); |
82 QVBoxLayout *vbox = new QVBoxLayout; |
66 QVBoxLayout *vbox = new QVBoxLayout; |
83 vbox->setMargin(0); |
67 vbox->setMargin(0); |
|
68 |
|
69 QDeclarativeView *view = new QDeclarativeView(b); |
|
70 view->setFocusPolicy(Qt::StrongFocus); |
|
71 view->setResizeMode(QDeclarativeView::SizeViewToRootObject); |
|
72 view->setSource(QUrl("qrc:/example.qml")); |
|
73 vbox->addWidget(view); |
84 b->setLayout(vbox); |
74 b->setLayout(vbox); |
85 |
75 // b->resize(800,480); |
86 QmlView *view = new QmlView(b); |
|
87 view->setFocusPolicy(Qt::StrongFocus); |
|
88 view->setContentResizable(true); |
|
89 view->setUrl(QUrl("qrc:/example.qml")); |
|
90 view->execute(); |
|
91 vbox->addWidget(view); |
|
92 b->resize(800,480); |
|
93 b->show(); |
76 b->show(); |
94 |
77 |
95 return app.exec(); |
78 return app.exec(); |
96 } |
79 } |