Okay, so managed to stumble upon this.
http://developer.qt.nokia.com/forums/viewthread/2093
Basically, it helped out a lot. Although I have some questions for you pro's.
1. The dude who made the thread in that link stated that he created three files.
1. Qt.md5(“mydb_nameâ€).ini
2. Qt.md5(“mydb_nameâ€).sqlite
3. Qt.md5(“mydb_nameâ€) folder
1. Qt.md5(“mydb_nameâ€).ini
2. Qt.md5(“mydb_nameâ€).sqlite
3. Qt.md5(“mydb_nameâ€) folder
To copy to clipboard, switch view to plain text mode
I saw the .ini and the .sqlite file. But I didn't see that folder. Is that even required? And where do you declare these Qt.md5(“mydb_nameâ€).ini? Inside your .cpp?
2. I did exactly what he did
QmlApplicationViewer viewer;
viewer.
engine()->setOfflineStoragePath
(QString(customPath
));
QmlApplicationViewer viewer;
viewer.engine()->setOfflineStoragePath(QString(customPath));
To copy to clipboard, switch view to plain text mode
where my custom path is set to "qml/OfflineStorage"
I created that qml/OfflineStorage path manually by navigating to the project folder and just creating a new folder, renaming it OfflineStorage and there's where I copied and pasted the .ini and .sqlite files I found on the default location. Is that right?
Here's the structure of my project:
\qml
\Projectproj
\main.qml
\data.txt
\OfflineStorage
\Databases
\9a41722cf143cae53004c21c7ec7b42f.ini
\9a41722cf143cae53004c21c7ec7b42f.sql
\qml
\Projectproj
\main.qml
\data.txt
\OfflineStorage
\Databases
\9a41722cf143cae53004c21c7ec7b42f.ini
\9a41722cf143cae53004c21c7ec7b42f.sql
To copy to clipboard, switch view to plain text mode
I also made sure that my qrc file was updated.
<!DOCTYPE RCC><RCC version="1.0">
<qresource>
<file>qml/Projectproj/data.txt</file>
<file>qml/OfflineStorage/Databases/9a41722cf143cae53004c21c7ec7b42f.ini</file>
<file>qml/OfflineStorage/Databases/9a41722cf143cae53004c21c7ec7b42f.sqlite</file>
</qresource>
</RCC>
<!DOCTYPE RCC><RCC version="1.0">
<qresource>
<file>qml/Projectproj/data.txt</file>
<file>qml/OfflineStorage/Databases/9a41722cf143cae53004c21c7ec7b42f.ini</file>
<file>qml/OfflineStorage/Databases/9a41722cf143cae53004c21c7ec7b42f.sqlite</file>
</qresource>
</RCC>
To copy to clipboard, switch view to plain text mode
Is that right? Do I include the Databases folder in the filepath?
And when I ran the application, it didn't read the database stored in the default location (C:/Users/...) since i set the custom path to qml/OfflineStorage
Here's my main.cpp
QDeclarativeEngine engine;
QString customPath
= "qml/OfflineStorage";
QmlApplicationViewer viewer;
viewer.
engine()->setOfflineStoragePath
(QString(customPath
));
viewer.setOrientation(QmlApplicationViewer::ScreenOrientationLockPortrait);
viewer.
setMainQmlFile(QLatin1String("qml/Projectproj/main.qml"));
viewer.showExpanded();
return app.exec();
QApplication app(argc, argv);
QDeclarativeEngine engine;
QString customPath = "qml/OfflineStorage";
QmlApplicationViewer viewer;
viewer.engine()->setOfflineStoragePath(QString(customPath));
viewer.setOrientation(QmlApplicationViewer::ScreenOrientationLockPortrait);
viewer.setMainQmlFile(QLatin1String("qml/Projectproj/main.qml"));
viewer.showExpanded();
return app.exec();
To copy to clipboard, switch view to plain text mode
I wanna know what I'm doing wrong.
EDIT:
Well, I finally got it to work. The database opens. ALTHOUGH, how come I can't SAVE any data to my database?? When I use the default path -> C:/Users... etc, and I try to INSERT, it works. But when I set the customOfflineStoragePath, it does INSERT yes, but when I close the application and run it again, the database didn't change at all. How come?
Bookmarks