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

Calling a funciton.

$
0
0
I’m using this file/function to load and display a database. import QtQuick 2.0 import QtQuick.LocalStorage 2.0   Text { text: "empty" x:350 y:360   function get_db(a) {     var db = LocalStorage.openDatabaseSync("DB2", "1.0", "The Example QML SQL!", 1000000);     db.transaction(         function(tx) {             tx.executeSql('CREATE TABLE IF NOT EXISTS Greeting(salutation TEXT, salutee TEXT)');            /* for ( var z=0; z<10; z++){             tx.executeSql('INSERT INTO Greeting VALUES(?, ?)', [ z, z ]);             }            tx.executeSql('INSERT INTO Greeting VALUES(?, ?)', [ 'A', 'MOVIE' ]);*/             var rs = tx.executeSql('SELECT * FROM Greeting');             var r = ""             for(var i = 0; i < a; i++) {                 r += rs.rows.item(i).salutation + ", " + rs.rows.item(i).salutee + "\t\t\t"             }             text = r         })} //Component.onCompleted: get_db(2) } I’d like to able to call this function from a mousearea for example get_db(5) from another file, this file being something like this. import "includes" .... .... ....                 MouseArea {                   id: mousearea1                   x: 569                   y: 271                   width: 141                   height: 210                   onClicked:{                       page.state = 'State1'                       get_db(5)                     }                   } but get_db(5) doesn’t work.

Viewing all articles
Browse latest Browse all 4972

Trending Articles