PDA

View Full Version : Qml_database



ganeshgladish
14th March 2013, 15:49
hi,
i am beginner for qt...i have small doubt in qml ...i want to create simple database save and retrieve from gui...anyone please help me.....

alizadeh91
14th March 2013, 15:54
In qml you have to use JavaScript for that as i know.

ganeshgladish
14th March 2013, 16:00
thank you for your replay sir,

can u please tell some examples code then i will understand ...please sir

wysota
14th March 2013, 16:03
hi,
i am beginner for qt...i have small doubt in qml ...i want to create simple database save and retrieve from gui...anyone please help me.....

You can use local storage API (see the docs for details) or expose a full blown database interface from C++.

alizadeh91
14th March 2013, 16:17
In qt5 you can use a QObject and expose it into qml for that also :) in Qt4 the procedure is similar.

ganeshgladish
14th March 2013, 16:18
thank you for your reply,
please give tell example program or sites sir ...

alizadeh91
14th March 2013, 17:48
First of all you can write your own c++ class from QObject. Do your work with database in this class. Then for using this class in qml you have to register it:


qmlRegisterType<MyObject>("QtQuick", 1, 0, "MyObject");

then in your qml, just import your custom type and use it.

see this: http://qt-project.org/doc/qt-5.0/qtqml/qtqml-cppintegration-contextproperties.html for embedding qobject in qml in Qt5

wysota
14th March 2013, 19:50
thank you for your reply,
please give tell example program or sites sir ...

http://qt-project.org/doc/qt-5.0/qtquick/qmlmodule-qtquick-localstorage2-qtquick-localstorage-2.html