<html><head><meta http-equiv="Content-Type" content="text/html charset=iso-8859-1"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">Hoi Chris<div><br></div><div>I will use the localstorage for my settings, so a blog entry would very much be appreciated :-)</div><div><br></div><div>My main DB is however opened in C++, to do this I use the QSqlDatabase class.</div><div>it then fails with out of memory on  open(). In Alpha 1 it worked perfectly.</div><div><ol style="margin: 1em 0px; padding: 5px 0px; font-family: 'Open Sans', sans-serif; list-style-position: inside; list-style-image: initial; color: rgb(175, 175, 175); font-size: 13px; line-height: 16px; text-align: left; background-color: rgb(255, 255, 255); "><li class="li1" style="margin: 0px 0px 0px 32px; padding: 0px 0px 0px 12px; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace; list-style: decimal; line-height: 14px; background-image: none; border-left-width: 3px; border-left-style: solid; border-left-color: rgb(108, 226, 108); position: static; z-index: auto; "><div class="de1" style="margin: 0px; padding: 0px; font-family: 'Open Sans', sans-serif !important; color: rgb(0, 0, 0); "><a href="http://qt-project.org/doc/QSqlDatabase.html" style="margin: 0px; padding: 0px; color: rgb(68, 165, 28); text-decoration: none; "><span class="kw5" style="margin: 0px; padding: 0px; font-weight: bold; ">QSqlDatabase</span></a> db <span class="sy0" style="margin: 0px; padding: 0px; color: rgb(54, 53, 52); ">=</span> <a href="http://qt-project.org/doc/QSqlDatabase.html" style="margin: 0px; padding: 0px; color: rgb(68, 165, 28); text-decoration: none; "><span class="kw5" style="margin: 0px; padding: 0px; font-weight: bold; ">QSqlDatabase</span></a><span class="sy0" style="margin: 0px; padding: 0px; color: rgb(54, 53, 52); ">:</span>addDatabase<span class="br0" style="margin: 0px; padding: 0px; color: rgb(54, 53, 52); ">(</span><span class="st0" style="margin: 0px; padding: 0px; color: blue; ">"QSQLITE"</span><span class="br0" style="margin: 0px; padding: 0px; color: rgb(54, 53, 52); ">)</span><span class="sy0" style="margin: 0px; padding: 0px; color: rgb(54, 53, 52); ">;</span></div></li><li class="li1" style="margin: 0px 0px 0px 32px; padding: 0px 0px 0px 12px; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace; list-style: decimal; line-height: 14px; background-image: none; border-left-width: 3px; border-left-style: solid; border-left-color: rgb(108, 226, 108); position: static; z-index: auto; "><div class="de1" style="margin: 0px; padding: 0px; font-family: 'Open Sans', sans-serif !important; color: rgb(0, 0, 0); ">db.<span class="me1" style="margin: 0px; padding: 0px; color: rgb(54, 53, 52); ">setDatabaseName</span><span class="br0" style="margin: 0px; padding: 0px; color: rgb(54, 53, 52); ">(</span><span class="st0" style="margin: 0px; padding: 0px; color: blue; ">pathToDB</span><span class="br0" style="margin: 0px; padding: 0px; color: rgb(54, 53, 52); ">)</span><span class="sy0" style="margin: 0px; padding: 0px; color: rgb(54, 53, 52); ">;</span></div></li><li class="li1" style="margin: 0px 0px 0px 32px; padding: 0px 0px 0px 12px; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace; list-style: decimal; line-height: 14px; background-image: none; border-left-width: 3px; border-left-style: solid; border-left-color: rgb(108, 226, 108); "><div class="de1" style="margin: 0px; padding: 0px; font-family: 'Open Sans', sans-serif !important; color: rgb(0, 0, 0); "><span class="kw4" style="margin: 0px; padding: 0px; color: rgb(210, 0, 32); font-weight: bold; ">bool</span> opened <span class="sy0" style="margin: 0px; padding: 0px; color: rgb(54, 53, 52); ">=</span> db.<span class="me1" style="margin: 0px; padding: 0px; color: rgb(54, 53, 52); ">open</span><span class="br0" style="margin: 0px; padding: 0px; color: rgb(54, 53, 52); ">(</span><span class="br0" style="margin: 0px; padding: 0px; color: rgb(54, 53, 52); ">)</span><span class="sy0" style="margin: 0px; padding: 0px; color: rgb(54, 53, 52); ">;</span></div></li></ol><div><br></div></div><div><br></div><div>I checked the VM memory, and its was 1 GB, so it should be enough.</div><div>This evening I will try to increase it, but I cannot understand why just opening the DB should use so much memory. Does anybody know how I can debug this, or if there are some SQLITE specific options that I must set?</div><div><br></div><div>Opening the db in the sqlite3 command line client works in the simulator, so I'm confident that the DB is not corrupted.</div><div><br></div><div>Greetings from Zürich</div><div>Erlend</div><div><br><div><div><div>On 05.08.2013, at 10:23, <a href="mailto:christopher.lamb@thurweb.ch">christopher.lamb@thurweb.ch</a> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite">Sali Erlend<br><br>Sorry, pressed send too soon on my last ...<br><br>How exactly are you trying to access Sqlite? via QtQuick LocalStorage API, or by some other means?<br><br>The error message you quote sounds as though the Emulator is having problems opening a 1.7 GB Database due to memory problems. I think the memory allocated to the Emulator VM is fairly low, so you might try increasing it.<br><br>In the meantime I have just managed to migrate LocalStorage DB to Qt5. I had to make a few changes to do so, and tore quite a bit of hair out until I hit the correct solution. I can provide examples if it helps (and will update my blog during the day)<br><br>Chris<br><br>p.s Hoi sounds Swiss (or Swiss aware ..)<br><br><br>----- Weitergeleitete Nachricht von <a href="mailto:christopher.lamb@thurweb.ch">christopher.lamb@thurweb.ch</a> -----<br>     Datum: Mon, 05 Aug 2013 10:16:04 +0200<br>       Von: <a href="mailto:christopher.lamb@thurweb.ch">christopher.lamb@thurweb.ch</a><br>   Betreff: Re:sqlite "out of memory" error<br>        An: "Erlend Boe" <<a href="mailto:erlendboe@yahoo.com">erlendboe@yahoo.com</a>><br>        Cc: <a href="mailto:devel@lists.sailfishos.org">devel@lists.sailfishos.org</a><br><br>Zitat von "Erlend Boe" <<a href="mailto:erlendboe@yahoo.com">erlendboe@yahoo.com</a>>:<br><br><blockquote type="cite">Hoi Chris<br><br>after using the patch, it is also working for me.<br><br>However, I have some other problems:<br>* opening my sqlite DB (1.7 GB) fails with  QSqlError(-1, "Error opening database", "out of memory")<br>* debugging fails with "connection to remote server failed: tcp:localhost:10000: Bad file descriptor. (although the application Output shows  "Listening on port 10000")<br><br>opening the db worked fine in the previous release.<br>Does anybody know what would cause this problem, or how I can debug it?<br><br><br>I'm using a mac with osx 10.8.4, and virtualbox 4.2.16.<br>I can log on to the simulator with: ssh -i ~/SailfishOS/vmshare/ssh/private_keys/1/root root@localhost -p 2223<br><br>Regards<br>Erlend<br><br><br><br>On 04.08.2013, at 18:56, <a href="mailto:christopher.lamb@thurweb.ch">christopher.lamb@thurweb.ch</a> wrote:<br><br><blockquote type="cite">Hi All<br><br>Just a quick note to say that<br><br>Q_DECL_EXPORT int main(int argc, char *argv[])<br>{<br>  QScopedPointer<QGuiApplication> app(Sailfish::createApplication(argc, argv));<br>  QScopedPointer<QQuickView> view(Sailfish::createView());<br>  view->rootContext()->setContextProperty("cppproperty",  "Hello world");<br>  Sailfish::setView(view.data(), "main.qml");<br>  Sailfish::showView(view.data());<br>  return app->exec();<br>}<br><br>works (so far) without error if Lucien's patch to sailfishapplication.cpp is applied. This can be found here: <a href="https://lists.sailfishos.org/pipermail/devel/attachments/20130802/2367c686/attachment.cpp">https://lists.sailfishos.org/pipermail/devel/attachments/20130802/2367c686/attachment.cpp</a><br><br>Chris<br><br>----- Weitergeleitete Nachricht von <a href="mailto:christopher.lamb@thurweb.ch">christopher.lamb@thurweb.ch</a> -----<br>   Datum: Sun, 04 Aug 2013 18:36:06 +0200<br>     Von: <a href="mailto:christopher.lamb@thurweb.ch">christopher.lamb@thurweb.ch</a><br> Betreff: Re: [SailfishDevel] Alpha 2: passing simple properties<span class="Apple-tab-span" style="white-space:pre">     </span>from<span class="Apple-tab-span" style="white-space:pre">        </span>main.cpp to qml: A bug?<br>      An: "Lucien XU" <<a href="mailto:sfietkonstantin@free.fr">sfietkonstantin@free.fr</a>><br>      Cc: <a href="mailto:devel@lists.sailfishos.org">devel@lists.sailfishos.org</a><br><br>Salut Lucien<br><br>Maybe it is clearer with Code examples<br><br>I was doing this, which gives me an error, but seems to work!<br><br>Q_DECL_EXPORT int main(int argc, char *argv[])<br>{<br>  QScopedPointer<QGuiApplication> app(Sailfish::createApplication(argc, argv));<br>  QScopedPointer<QQuickView> view(Sailfish::createView("main.qml"));<br>  view->rootContext()->setContextProperty("cppproperty",  "Hello world");<br>  Sailfish::showView(view.data());<br>  return app->exec();<br>}<br><br>You suggest I could this:<br><br>Q_DECL_EXPORT int main(int argc, char *argv[])<br>{<br>  QScopedPointer<QGuiApplication> app(Sailfish::createApplication(argc, argv));<br>  QScopedPointer<QQuickView> view(Sailfish::createView());<br>  view->rootContext()->setContextProperty("cppproperty",  "Hello world");<br>  Sailfish::setView(view.data(), "main.qml");<br>  Sailfish::showView(view.data());<br>  return app->exec();<br>}<br><br>..but will then run into your template error:<br><a href="file:///usr/share/setContextPropertyDemo/main.qml:">file:///usr/share/setContextPropertyDemo/main.qml:</a> File not found<br><br>Maybe the qmlRegister**Type is the best approach after all. The downside is (unless I have missed something) that I will then have to create a class for my property, whereas with the setContextProperty I can use a string literal or a primitive type like int.<br><br>Merci<br><br>Chris<br><br><br>Zitat von "Lucien XU" <<a href="mailto:sfietkonstantin@free.fr">sfietkonstantin@free.fr</a>>:<br><br><blockquote type="cite">Hello guys !<br><br>It might be useful to use qmlRegister**Type (uncreatable, singleton etc.) to<br>expose C++ components to QML. But if you really want to use rootContext()-<br><blockquote type="cite">setContextProperty, you have to be cautious.<br></blockquote><br>Actually, if you pass the qml file to the view before registering C++<br>components, the QML components won't be able to see the C++ ones, so you have<br>to call setContextProperty before calling setSource (or calling the<br>createView("main.qml") method).<br><br>You have to call the parameter-less method createView(), and then, call<br>setView(QQuickView *, QString) to pass the source QML file.<br><br>But beware, there is a bug in the template. See<br><a href="https://lists.sailfishos.org/pipermail/devel/2013-August/000529.html">https://lists.sailfishos.org/pipermail/devel/2013-August/000529.html</a>.<br><br>Hopes it helps (because I'm not very clear in this mail)<br>Cheers,<br>Lucien<br><br>Le dimanche 4 août 2013 17:05:01 <a href="mailto:christopher.lamb@thurweb.ch">christopher.lamb@thurweb.ch</a> a écrit :<br><blockquote type="cite">Hi Martin<br><br>Curiouser and Curiouser!<br><br>Just to be sure, I went back and tested your suggestion in a demo<br>project based on the default "Hello Sailors" new project template.<br><br>Here I pass the c++ property cppproperty with the value "Hello World".<br>In the QML FirstPage this is concatenated to the "Hello Sailors" label<br>text.<br><br>I still get this error:<br><a href="file:///opt/sdk/setContextPropertyDemo/usr/share/setContextPropertyDemo/page">file:///opt/sdk/setContextPropertyDemo/usr/share/setContextPropertyDemo/page</a><br>s/FirstPage.qml:34: ReferenceError: cppproperty is not defined<br><br>Yet the app displays "Hello Sailors: Hello world".<br><br>So a property can be passed as you suggested, it can be used. The<br>error must be wrong!<br><br>Chris<br><br>P.s you test the same by creating a default new Sailfish project, and<br>replacing the main.cpp and FirstPage.qml with the code below.<br><br><br>//start main.cpp<br>#include <QGuiApplication><br>#include <QQuickView><br>#include <QQmlContext><br><br>#include "sailfishapplication.h"<br><br>Q_DECL_EXPORT int main(int argc, char *argv[])<br>{<br>  QScopedPointer<QGuiApplication><br>app(Sailfish::createApplication(argc, argv));<br>  QScopedPointer<QQuickView> view(Sailfish::createView("main.qml"));<br>  view->rootContext()->setContextProperty("cppproperty",  "Hello world");<br>Sailfish::showView(view.data());<br><br>  return app->exec();<br>}<br>//end main.cpp<br><br><br>//start FirstPage.qml<br>import QtQuick 2.0<br>import Sailfish.Silica 1.0<br>import Sailfish.Silica.theme 1.0<br><br><br>Page {<br>  id: page<br><br>  // To enable PullDownMenu, place our content in a SilicaFlickable<br>  SilicaFlickable {<br>      anchors.fill: parent<br><br>      // PullDownMenu and PushUpMenu must be declared in<br>SilicaFlickable, SilicaListView or SilicaGridView<br>      PullDownMenu {<br>          MenuItem {<br>              text: "Show Page 2"<br>              onClicked: pageStack.push(Qt.resolvedUrl("SecondPage.qml"))<br>}<br>      }<br><br>      // Tell SilicaFlickable the height of its content.<br>      contentHeight: childrenRect.height<br><br>      // Place our content in a Column.  The PageHeader is always<br>placed at the top<br>      // of the page, followed by our content.<br>      Column {<br>          width: page.width<br>          spacing: Theme.paddingLarge<br>          PageHeader {<br>              title: "UI Template"<br>          }<br>          Label {<br>              x: Theme.paddingLarge<br>              text: "Hello Sailors: " + cppproperty<br>              color: Theme.secondaryHighlightColor<br>              font.pixelSize: Theme.fontSizeLarge<br>          }<br>      }<br>  }<br>}<br>//end FirstPage.qml<br><br>Zitat von "Martin Grimme" <martin.grimme@gmail.com>:<br><blockquote type="cite">Hi,<br><br>you don't want to set the context property on the<br>QmlApplicationViewer, which was dead Nokia code to target Symbian and<br>Harmattan, anyway.<br>QmlApplicationViewer was derived from QmlView, where it got the<br>rootContext() method from.<br><br>With Qt5, QmlView was renamed to QQuickView. And when using the<br><br>functions from sailfishapplication.h, you get a QQuickView*, e.g.:<br>      QScopedPointer<QQuickView> view(Sailfish::createView("main.qml"));<br>      view->rootContext()->setContextProperty("platform", platformId);<br><br>Martin<br><br>2013/8/4, christopher.lamb@thurweb.ch <christopher.lamb@thurweb.ch>:<br><blockquote type="cite">Hi all<br><br>What is the recommended way to pass simple c++ properties from the<br>main.cpp to the QML part of a project using the Qt 5 Alpha?<br><br>In the good old days of the first Alpha, I used to do this Harmattan<br>style using<br><br>   QmlApplicationViewer viewer;<br>   viewer.rootContext()->setContextProperty("platform",  platformId);<br><br>This would make the c++ property platformId available to my qml code<br>as the property platform.<br><br>Now with Qt5 / Alpha 2 the QmlApplicationViewer is no longer created.<br><br>The tutorial linked below suggests that the QmlApplicationViewer files<br>could be ported to Qt5, so I guess I could grab these files from an<br>old Harmattan project and do that.<br><br>https://qt-project.org/doc/qt-5.0/qtdoc/portingqmlapp.html<br><br>But somehow that feels like carting old baggage around.<br><br>Is their a Sailfish native way of doing the same?<br><br>Thanks<br><br>Chris<br><br><br><br><br>_______________________________________________<br>SailfishOS.org Devel mailing list<br></blockquote></blockquote><br>_______________________________________________<br>SailfishOS.org Devel mailing list<br></blockquote>_______________________________________________<br><a href="http://SailfishOS.org">SailfishOS.org</a> Devel mailing list<br><br></blockquote><br><br>_______________________________________________<br><a href="http://SailfishOS.org">SailfishOS.org</a> Devel mailing list<br><br><br>----- Ende der weitergeleiteten Nachricht -----<br><br>_______________________________________________<br><a href="http://SailfishOS.org">SailfishOS.org</a> Devel mailing list<br></blockquote><br><br></blockquote><br><br><br><br>----- Ende der weitergeleiteten Nachricht -----<br><br><br></blockquote></div><br></div></div></body></html>