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. Load in listview one listmodel including table1database.js and table1database.js
Forum Updated to NodeBB v4.3 + New Features

Load in listview one listmodel including table1database.js and table1database.js

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
3 Posts 2 Posters 763 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.
  • F Offline
    F Offline
    filipdns
    wrote on 13 Dec 2017, 20:28 last edited by A Former User
    #1

    Hello, I'm using localstorage in QML and I must use 3 tables in database for 3 qml forms.
    In the 4th one I need to use data from 2 of the 3 tables.
    How can I add the second because with one and qml script below it's working:

     ListView {
                        id: listView
                        Layout.fillWidth: true
                        model: ListModel {
                               id: listModel
                               Component.onCompleted:
                               {
                                   JS2.dbavion(inConversationWith)
                               }
                        }
    

    but just with add the second table, the second one is not taking in account:

     ListView {
                        id: listView
                        Layout.fillWidth: true
                        model: ListModel {
                               id: listModel
                               Component.onCompleted:
                               {
                                   JS2.dbavion(inConversationWith)
                                   JS.dbimmat(inConversationWith)
                               }
                        }
    

    What is the good way to do what I need?

    Thanks you very much

    O 1 Reply Last reply 14 Dec 2017, 12:25
    0
    • F filipdns
      13 Dec 2017, 20:28

      Hello, I'm using localstorage in QML and I must use 3 tables in database for 3 qml forms.
      In the 4th one I need to use data from 2 of the 3 tables.
      How can I add the second because with one and qml script below it's working:

       ListView {
                          id: listView
                          Layout.fillWidth: true
                          model: ListModel {
                                 id: listModel
                                 Component.onCompleted:
                                 {
                                     JS2.dbavion(inConversationWith)
                                 }
                          }
      

      but just with add the second table, the second one is not taking in account:

       ListView {
                          id: listView
                          Layout.fillWidth: true
                          model: ListModel {
                                 id: listModel
                                 Component.onCompleted:
                                 {
                                     JS2.dbavion(inConversationWith)
                                     JS.dbimmat(inConversationWith)
                                 }
                          }
      

      What is the good way to do what I need?

      Thanks you very much

      O Offline
      O Offline
      ODБOï
      wrote on 14 Dec 2017, 12:25 last edited by
      #2

      @filipdns Hello,

      To construct 1 model with your 2 js files, you can extract informations you need inside your 2 files and than use 'append()' to add extracted informations to your model. myModel.append({name : value})

      1 Reply Last reply
      0
      • F Offline
        F Offline
        filipdns
        wrote on 14 Dec 2017, 19:56 last edited by filipdns
        #3

        Hello thanks a lot for your reply.
        What to you mean with extract informations I need inside my 2 files and than use 'append()' ?
        here that is information need in the first js:

        function dbpartbyata(Pimmatriculation,Pata)
        {
            var db = dbGetHandle()
            db.transaction(function (tx) {
                var results = tx.executeSql(
                            'SELECT rowid, ata, description, part, serial, immatriculation, sideinstallation, dateinstallation, heureinstallation, cycleinstallation, numerodossierinstallation, datedepose, motifdepose, heuredepose, cycledepose, numerodossierdepose, heureutilisation, cycleutilisation, jourutilisation, datelastrg, datelastinspection, nombrederg, tboheure, tbocycle, tbojour, potentielheure, potentielcycle, potentieljour FROM part_log where immatriculation=? AND ata = ?', [Pimmatriculation,Pata])
                for (var i = 0; i < results.rows.length; i++) {
                    listModel.append({
                                         id: results.rows.item(i).rowid,
                                         checked: " ",
                                         ata:results.rows.item(i).ata,
                                         description:results.rows.item(i).description,
                                         part:results.rows.item(i).part,
                                         serial:results.rows.item(i).serial,
                                         immatriculation:results.rows.item(i).immatriculation,
                                         sideinstallation:results.rows.item(i).sideinstallation,
                                         dateinstallation:results.rows.item(i).dateinstallation,
                                         heureinstallation:results.rows.item(i).heureinstallation,
                                         cycleinstallation:results.rows.item(i).cycleinstallation,
                                         numerodossierinstallation:results.rows.item(i).numerodossierinstallation,
                                         datedepose:results.rows.item(i).datedepose,
                                         motifdepose:results.rows.item(i).motifdepose,
                                         heuredepose:results.rows.item(i).heuredepose,
                                         cycledepose:results.rows.item(i).cycledepose,
                                         numerodossierdepose:results.rows.item(i).numerodossierdepose,
                                         heureutilisation:results.rows.item(i).heureutilisation,
                                         cycleutilisation:results.rows.item(i).cycleutilisation,
                                         jourutilisation:results.rows.item(i).jourutilisation,
                                         datelastrg:results.rows.item(i).datelastrg,
                                         datelastinspection:results.rows.item(i).datelastinspection,
                                         nombrederg:results.rows.item(i).nombrederg,
                                         tboheure:results.rows.item(i).tboheure,
                                         tbocycle:results.rows.item(i).tbocycle,
                                         tbojour:results.rows.item(i).tbojour,
                                         potentielheure:results.rows.item(i).potentielheure,
                                         potentielcycle:results.rows.item(i).potentielcycle,
                                         potentieljour:results.rows.item(i).potentieljour,
        
                                     })
                }
            })
        }
        

        and here information from the second js:

        function dbimmat(Pimmatriculation)
        {
            var db = dbGetHandle()
            db.transaction(function (tx) {
                var results = tx.executeSql(
                            'SELECT rowid,date_etape,  immatriculation,  pilot1,  pilot2,  pilot3,  photo1,  photo2,  photo3,  aeroport_depart,  aeroport_arrivee,  heure_depart, heure_arrivee,  temps_bloc_etape,  cycle_etape,  temps_bloc_jour,  cycle_jour,  heure_cellule_etape,  cycle_cellule_etape,  heure_cellule_jour,  cycle_cellule_jour,  heure_moteur_1_etape,  heure_moteur_2_etape,  heure_moteur_1_jour,  heure_moteur_2_jour, heure_SN_moteur_1, heure_SO_moteur_1, heure_SH_moteur_1, cycle_SN_moteur_1,  cycle_SO_moteur_1, cycle_SH_moteur_1,  heure_SN_moteur_2,  heure_SO_moteur_2,  heure_SH_moteur_2,  cycle_SN_moteur_2,  cycle_SO_moteur_2, cycle_SH_moteur_2 FROM flight_hours where immatriculation=?', [Pimmatriculation])
                for (var i = 0; i < results.rows.length; i++) {
                    listModel.append({
                                         id: results.rows.item(i).rowid,
                                         checked: " ",
                                         date_etape:results.rows.item(i).date_etape,
                                         immatriculation: results.rows.item(i).immatriculation,
                                         pilot1:results.rows.item(i).pilot1,
                                         pilot2:results.rows.item(i).pilot2,
                                         pilot3:results.rows.item(i).pilot3,
                                         photo1:results.rows.item(i).photo1,
                                         photo2:results.rows.item(i).photo2,
                                         photo3:results.rows.item(i).photo3,
                                         aeroport_depart:results.rows.item(i).aeroport_depart,
                                         aeroport_arrivee:results.rows.item(i).aeroport_arrivee,
                                         heure_depart:results.rows.item(i).heure_depart,
                                         heure_arrivee:results.rows.item(i).heure_arrivee,
                                         temps_bloc_etape:results.rows.item(i).temps_bloc_etape,
                                         cycle_etape:results.rows.item(i).cycle_etape,
                                         temps_bloc_jour:results.rows.item(i).temps_bloc_jour,
                                         cycle_jour:results.rows.item(i).cycle_jour,
                                         heure_cellule_etape:results.rows.item(i).heure_cellule_etape,
                                         cycle_cellule_etape:results.rows.item(i).cycle_cellule_etape,
                                         heure_cellule_jour:results.rows.item(i).heure_cellule_jour,
                                         cycle_cellule_jour:results.rows.item(i).cycle_cellule_jour,
                                         heure_moteur_1_etape:results.rows.item(i).heure_moteur_1_etape,
                                         heure_moteur_2_etape:results.rows.item(i).heure_moteur_2_etape,
                                         heure_moteur_1_jour:results.rows.item(i).heure_moteur_1_jour,
                                         heure_moteur_2_jour:results.rows.item(i).heure_moteur_2_jour,
                                         heure_SN_moteur_1:results.rows.item(i).heure_SN_moteur_1,
                                         heure_SO_moteur_1:results.rows.item(i).heure_SO_moteur_1,
                                         heure_SH_moteur_1:results.rows.item(i).heure_SH_moteur_1,
                                         cycle_SN_moteur_1:results.rows.item(i).cycle_SN_moteur_1,
                                         cycle_SO_moteur_1:results.rows.item(i).cycle_SO_moteur_1,
                                         cycle_SH_moteur_1:results.rows.item(i).cycle_SH_moteur_1,
                                         heure_SN_moteur_2:results.rows.item(i).heure_SN_moteur_2,
                                         heure_SO_moteur_2:results.rows.item(i).heure_SO_moteur_2,
                                         heure_SH_moteur_2:results.rows.item(i).heure_SH_moteur_2,
                                         cycle_SN_moteur_2:results.rows.item(i).cycle_SN_moteur_2,
                                         cycle_SO_moteur_2:results.rows.item(i).cycle_SO_moteur_2,
                                         cycle_SH_moteur_2:results.rows.item(i).cycle_SH_moteur_2,
        
                                     })
                }
            })
        }
        

        Thank you for your help

        1 Reply Last reply
        0

        3/3

        14 Dec 2017, 19:56

        • Login

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