do we have example show how to edit and display sqlite data in tableview in QML?
-
Hi,
From a quick look at the documentation, i think you can start with:
- https://doc.qt.io/qt-6/qtquick-modelviewsdata-modelview.html#changing-model-data on how to configure your delegate to be read/write
And for the model: - https://wiki.qt.io/How_to_Use_a_QSqlQueryModel_in_QML to give you a base for a read-only model
Implement thesetDatafor your custom model
Note I haven't done that yet, it's just putting some elements together.
Hope it helps
- https://doc.qt.io/qt-6/qtquick-modelviewsdata-modelview.html#changing-model-data on how to configure your delegate to be read/write
-
here is my code ,i open the database and add data manualy ,but i think the model does not connect to the database, so no data is displayed in the view.

main.qml
import QtQuick import QtQuick.Effects import QtQuick.Controls import QtQuick.Layouts import Charts ApplicationWindow { id:root width: 640 height: 480 visible: true color: 'white' title: qsTr("Hello World") footer: ToolBar { id: statusBar height: 30 Label { id: statusLabel anchors.fill: parent anchors.leftMargin: 10 verticalAlignment: Text.AlignVCenter text: "ready" } } // table SqlTable{ anchors.fill: parent } } -
here is my code ,i open the database and add data manualy ,but i think the model does not connect to the database, so no data is displayed in the view.

main.qml
import QtQuick import QtQuick.Effects import QtQuick.Controls import QtQuick.Layouts import Charts ApplicationWindow { id:root width: 640 height: 480 visible: true color: 'white' title: qsTr("Hello World") footer: ToolBar { id: statusBar height: 30 Label { id: statusLabel anchors.fill: parent anchors.leftMargin: 10 verticalAlignment: Text.AlignVCenter text: "ready" } } // table SqlTable{ anchors.fill: parent } } -
QSqlTableModel + TableView sounds like what you need



