Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Using qml sql to pull data but how can I use it to be displayed.
Forum Updated to NodeBB v4.3 + New Features

Using qml sql to pull data but how can I use it to be displayed.

Scheduled Pinned Locked Moved QML and Qt Quick
2 Posts 2 Posters 1.1k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    dstudentx
    wrote on last edited by
    #1

    I'm using this .js

    @
    var index_count = 0
    var up_check = 0
    function get_db(a, up_check) {

    var db = LocalStorage.openDatabaseSync("DB5", "1.0", "The Example QML SQL!", 10000);
    db.transaction(
        function(tx) {
          /*  tx.executeSql('CREATE TABLE IF NOT EXISTS Greeting(salutation TEXT, salutee TEXT)');
            for ( var z=0; z<1000; z++){
               tx.executeSql('INSERT INTO Greeting VALUES(?, ?)', [ 'Movie', z ]);
            }
          */
           var rs = tx.executeSql('SELECT * FROM Greeting');
           var r = ""
    
                for(var i = 0; i < a; i++) {
                     if (i>index_count-1 && up_check ===0)
                        r += rs.rows.item(i).salutation + ": " + rs.rows.item(i).salutee + "\t\t"
    
                     if (up_check === 1){
                         var size_check =0
                         if (i >index_count-11   && size_check !==9)  {
                           r += rs.rows.item(i).salutation + ": " + rs.rows.item(i).salutee + "\t\t"
                          size_check++
                         }
                      }
                  }
           console.log(r);
           index_count=a;
            return r;
        })}
    

    @

    for pulling data from a database and this is how I'm calling the function from the qml
    @ Logic.get_db(5,0)@

    How can I use the data pulled from the function to use like an imge or txt in qtquick
    I'd love to be able to place the data in specific spots.

    1 Reply Last reply
    0
    • S Offline
      S Offline
      SlimIT
      wrote on last edited by
      #2

      I think that you can find in this "learning guide":http://releases.qt-project.org/learning/developerguides/qtquickdesktop/QtQuickApplicationGuide4Desktop.pdf how to read from the database.

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved