Quantcast
Channel: Qt DevNet forums: Qt Quick 1283365070**
Viewing all articles
Browse latest Browse all 4972

[Solved] ReferenceError: openDatabaseSync is not defined

$
0
0
After some trying I found a way to make it work. Since this is my first time using QtQuick I’m not sure if this is a good solution (I doubt it). Nevertheless I will still post my findings if anybody else is in need of it. My Solution no longer uses a .js but instead I tried the approach via .qml as shown here: http://qt-project.org/doc/qt-5.0/qtquick/qmlmodule-qtquick-localstorage2-qtquick-localstorage-2.html (I also corrected the errors in the sql queries.) Database.qml import QtQuick 2.0 import QtQuick.LocalStorage 2.0   Item {       property var db       Component.onCompleted: {         db = LocalStorage.openDatabaseSync("Hangman", "1.0", "hangmandb", 100000,db);         init();     }       function init() {         db.transaction(function(tx) {             tx.executeSql("CREATE TABLE IF NOT EXISTS user(Id INTEGER PRIMARY KEY AUTOINCREMENT, Moderator INTEGER, Admin INTEGER, Name TEXT NOT NULL);");             tx.executeSql("INSERT OR REPLACE INTO user (Moderator,Admin,Name) VALUES (1,1,\"Admin\");");             tx.executeSql("CREATE TABLE IF NOT EXISTS score(Id INTEGER PRIMARY KEY AUTOINCREMENT, UserId INTEGER, LV1Win INTEGER, LV1Lose INTEGER, LV1Cancel INTEGER, LV2Win Integer, LV2Lose Integer, LV2Cancel INTEGER, LV3Win INTEGER, LV3Lose INTEGER, LV3Cancel INTEGER, FOREIGN KEY(UserId) REFERENCES user(Id));");             tx.executeSql("CREATE TABLE IF NOT EXISTS topics(Id INTEGER PRIMARY KEY AUTOINCREMENT, Name TEXT NOT NULL);");         });     } } main.qml import QtQuick 2.0   Rectangle {     id: root     width: 1280     height: 720       KeyHandling {} // everything related to onPress events is handled in this file     MenuGeneric { id: menuGeneric }     MenuPlayers { id: menuPlayers }     MenuOverlay { id: menuOverlay }       property Database db       Component.onCompleted: {         db = Qt.createComponent("Database.qml").createObject();     } }

Viewing all articles
Browse latest Browse all 4972

Trending Articles