Results 1 to 6 of 6

Thread: QT QML OfflineDatabaseAPI

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    May 2007
    Posts
    131
    Thanks
    17
    Thanked 4 Times in 2 Posts

    Default Re: QT QML OfflineDatabaseAPI

    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.
    Qt Code:
    1. 1. Qt.md5(“mydb_name”).ini
    2. 2. Qt.md5(“mydb_name”).sqlite
    3. 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
    Qt Code:
    1. QmlApplicationViewer viewer;
    2. 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:
    Qt Code:
    1. \qml
    2. \Projectproj
    3. \main.qml
    4. \data.txt
    5. \OfflineStorage
    6. \Databases
    7. \9a41722cf143cae53004c21c7ec7b42f.ini
    8. \9a41722cf143cae53004c21c7ec7b42f.sql
    To copy to clipboard, switch view to plain text mode 

    I also made sure that my qrc file was updated.
    Qt Code:
    1. <!DOCTYPE RCC><RCC version="1.0">
    2. <qresource>
    3. <file>qml/Projectproj/data.txt</file>
    4. <file>qml/OfflineStorage/Databases/9a41722cf143cae53004c21c7ec7b42f.ini</file>
    5. <file>qml/OfflineStorage/Databases/9a41722cf143cae53004c21c7ec7b42f.sqlite</file>
    6. </qresource>
    7. </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
    Qt Code:
    1. QApplication app(argc, argv);
    2. QDeclarativeEngine engine;
    3. QString customPath = "qml/OfflineStorage";
    4. QmlApplicationViewer viewer;
    5. viewer.engine()->setOfflineStoragePath(QString(customPath));
    6. viewer.setOrientation(QmlApplicationViewer::ScreenOrientationLockPortrait);
    7. viewer.setMainQmlFile(QLatin1String("qml/Projectproj/main.qml"));
    8. viewer.showExpanded();
    9. 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?
    Last edited by bmn; 9th August 2011 at 20:17.

  2. #2
    Join Date
    May 2007
    Posts
    131
    Thanks
    17
    Thanked 4 Times in 2 Posts

    Default Re: QT QML OfflineDatabaseAPI

    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?

  3. #3
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,018 Times in 4,794 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QT QML OfflineDatabaseAPI

    Because resource files are read-only. Stop shooting blind and start reading the documentation instead of gathering incoherent code snippets from all over the web trying to stitch them all toghether to complete your school assignment.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.