[Qt-qml] A simple, complete example of QML onvoking C++?
Peter Matuchniak
pmatuchniak at imsco-us.com
Tue Apr 13 22:03:26 CEST 2010
Thanks Colin & Brett for your examples and input. I am seeing a strange problem with regards to text not showing when using the "DeclarativeView" approach -- this has to be a bug or something that's different when running it through the regular QML viewer.
I created a simple QML page with some text in it next to a colored rectangle:
- using QML viewer this page displays fine (both text and rectangle display)
- using the self-built C++ code based on your input I see no text (only the rectangle)
The other approach that Colin offered resembles the QML documentation, but:
- using the self-built C++ code the QML window never displays.
Note that I am using the Qt 4.7.0 application framework, built from source on a Ubuntu VM...
Kind regards
Peter
-----Original Message-----
From: Colin Kern [mailto:colin.kern at gmail.com]
Sent: Tuesday, April 13, 2010 12:05 PM
To: Peter Matuchniak
Cc: qt-qml at trolltech.com
Subject: Re: [Qt-qml] A simple, complete example of QML onvoking C++?
On Tue, Apr 13, 2010 at 2:52 PM, Peter Matuchniak
<pmatuchniak at imsco-us.com> wrote:
> Hello Colin
>
> Thanks for the input. Although it compiles fine and appears to run without any errors, I don't actually see the QML page appear (i.e. myqml.qml is never displayed).
>
> I'm using Qt 4.7 that I built from source on Ubuntu.
>
Ok, I guess that code in main.cpp never actually displays the widget.
I took that from the QDeclarative documentation, but I'm not sure what
its use is if it doesn't display anything. Try this main.cpp:
#include "foo.h"
#include <QDeclarativeView>
int main(int argc, char **argv)
{
QApplication app(argc, argv);
QDeclarativeView *view = new QDeclarativeView();
view->rootContext()->setContextProperty("myFoo", new Foo);
view->setSource(QUrl("myqml.qml"));
view->show();
return app.exec();
}
Colin
---------------------------------------------------------------------------
This email and any files transmitted with it are confidential & proprietary to Systems and
Software Enterprises, Inc. (dba IMS). This information is intended solely for the use of
the individual or entity to which it is addressed. Access or transmittal of the information
contained in this e-mail, in full or in part, to any other organization or persons is not
authorized.
---------------------------------------------------------------------------
More information about the Qt-qml
mailing list