Hi, This example is useful for me too, but i've a question about the plugins example of qt examples, if i compile it and try to execute "qml plugins.qml" nothing appears in qmlviewer, something is wrong in the qmldir or miss something ?
Another question is if i create a plugin in a tree like "plugins/graphic/base" how can i access it from a QApplication, i must use QDeclarativeEngine or QDeclarativeView and set Engine ImportPath() ? Is someone have an example of that ? Thanks. FLORET Alain Developer CORYS TESS E-mail : [email protected] -- Le 15/04/2010 07:22, [email protected] a écrit : > Hi Peter, > > I'm uncertain whether it now works for you or not. If it doesn't, please > ensure the qml viewer has been built with the very same Qt as you build the > plugin, and if this still fails, please post the output you get when > debugging with QML_IMPORT_TRACE=1. > > I did build and run the example on both Linux and Windows, so technically it > is correct. > > Matthias > ________________________________________ > From: ext Peter Matuchniak [[email protected]] > Sent: Wednesday, April 14, 2010 6:35 PM > To: Ettrich Matthias (Nokia-D-Qt/Berlin); [email protected] > Subject: RE: [Qt-qml] Plugin example [was: Re: A simple,complete example of > QML onvoking C++?] > > Hello Matthias > > Thanks for sharing your example -- this is exactly the kind of sample needed > :-) > > A few points: > > - in the QML file, don't we need to add a line to refer to the shared object, > i.e. something like this: "import NativeBackend" > > - I get this runtime error (presumably because of the missing import?) > file:///.../button/Button.qml:6:5: Type NativeBackend unavailable > NativeBackend { id: nativeBackend; } > > - during my initial build attempt, there seemed to be an endless loop of > messages saying: > "button.pro has a future date" > This is probably because you are in a later timezone than me? > Anyway, I got around this by re-saving each of the files with my local > time and all was well after that > > Kind regards > Peter > > > > -----Original Message----- > From: [email protected] [mailto:[email protected]] On > Behalf Of Matthias Ettrich > Sent: Wednesday, April 14, 2010 7:08 AM > To: [email protected] > Subject: [Qt-qml] Plugin example [was: Re: A simple,complete example of QML > onvoking C++?] > > Hi, > > attached is a small example button.zip which demonstrates how to create a C++ > plugin which can be used fom qml. The plugin implements a native type called > NativeBackend which implements a C++ function called nativeFunction(). > > An instance of NativeBackend is instantiated declaratively in Button.qml. > > Unzip, cd to button, call qmake, make and run it with qml Button.qml. > Clicking on the text label will change the text to the return value of the > native function. > > The file qmldir has to live in the same directory as Button.qml. The engine > parses it automatically when loading Button.qml. The files contains the > single line "plugin nativebackend lib" which makes the engine expect a plugin > binary in the lib subdirectory. > > If you run qml with QML_IMPORT_TRACE=1 you will also get debug output from > the import loading mechanism: > > ~/tmp/button$ QML_IMPORT_TRACE=1 qml Button.qml > QDeclarativeEngine::addImportPath "/home/ettrich/dev/qt-qml/bin" > QDeclarativeEngine::addToImport 0xeffa70 "." -1.-1 File as "" > QDeclarativeEngine::add: loaded "/home/ettrich/tmp/button/qmldir" > QDeclarativeEngine::importPlugin ".home.ettrich.tmp.button" from > "/home/ettrich/tmp/button/lib/libnativebackend.so" > QDeclarativeEngine::addToImport 0xeffa70 "Qt" 4.6 Library as "" > QDeclarativeEngine::resolveType "Rectangle" = "QDeclarativeRectangle" > QDeclarativeEngine::resolveType "NativeBackend" = "NativeBackend" > QDeclarativeEngine::resolveType "Text" = "QDeclarativeText" > QDeclarativeEngine::resolveType "MouseArea" = "QDeclarativeMouseArea" > Wall startup time: 7 > > > Matthias > > > > --------------------------------------------------------------------------- > 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. > --------------------------------------------------------------------------- > > _______________________________________________ > Qt-qml mailing list > [email protected] > http://lists.trolltech.com/mailman/listinfo/qt-qml > > > _______________________________________________ Qt-qml mailing list [email protected] http://lists.trolltech.com/mailman/listinfo/qt-qml
