L'utilisation de QslQueryModel sur c++ et Quick
Solved
French
-
Bonsoir tout le monde ❤️
Enfaite j'essaie d'afficher des données depuis la base données MySQL
Code source
Main.qmlFrame{ Layout.fillHeight: true Layout.fillWidth: true Flickable { anchors.fill: parent Text { id: text1 anchors.verticalCenterOffset: 20 anchors.horizontalCenter: parent.horizontalCenter text: qsTr("Top les enquêtes ouvertes Récemment") font.pixelSize: 18 font.bold: true } ListView { id: list_view1 anchors.fill: parent anchors.topMargin: 20 delegate: DataItemDelegate {} model: sqlQuery } } }
DataItemDelegatr.qml
Item { id: delegate //anchors.fill: parent width: delegate.ListView.view.width; height: 300 clip: true anchors.margins: 4 RowLayout { anchors.margins: 4 anchors.fill: parent spacing: 4; Text { text: sqlQuery.nom("grade", 0) width: 150 } Text { text: sqlQuery.nom("nom", 0) width: 150; } Text { text: sqlQuery.nom("service", 0) width: 50; } } }
La fonction qui me permet de récupérer le donnée
QString SqlQueryModel::nom(QString name, int index) { QSqlQueryModel model; model.setQuery(QString("SELECT * FROM piédestal")); return model.data(model.index(0, 0)).toString(); }
Petite problème j'arrive pas a récupérer tous les lignes ou tous les textes enregistrés sur la base de données
-