qml editable table creation
-
import QtQuick.Extras 1.4
import QtQuick.Layouts 1.3
import QtQuick.Controls 2.12
import QtQuick.Window 2.12
import QtQuick 2.12
Window {
id: window
visible: true
width: 1280
height: 700
title: qsTr("Hello World")Button { id: button x: 1009 y: 623 text: qsTr("Connect") onClicked: { stackLayout.currentIndex = 1; // Show page 2 } } Button { id: button1 x: 177 y: 623 text: qsTr("Table") onClicked: { stackLayout.currentIndex = 0; // Show page 2 } } Button { id: button2 x: 581 y: 623 text: qsTr("Clear") anchors.horizontalCenter: parent.horizontalCenter } StackLayout { id: stackLayout x: 0 y: 0 width: 1280 height: 576 currentIndex: 0 Rectangle { id: rectangle width: stackLayout.width height: stackLayout.height color: "lightblue" TableView { id: tableView1 x: 336 y: 104 width: 599 height: 367 model: ListModel { ListElement { name: "Item 1" value: 10 } ListElement { name: "Item 2" value: 20 } ListElement { name: "Item 3" value: 30 } } delegate: Item { TextField { text: model.name onTextChanged: { model.name = text } } } TableViewColumn { role: "value" title: "Value" width: 100 } TableViewColumn { role: "value" title: "Value" width: 100 } TableViewColumn { role: "value" title: "Value" width: 100 } TableViewColumn { role: "value" title: "Value" width: 100 } } } Rectangle { width: stackLayout.width height: stackLayout.height color: "lightgreen" K3connecter { id: k3connecter1 x: 899 y: 128 } K3connecter { id: k3connecter x: 108 y: 128 } } }
}
This is my qml code to create a table inside a stacked layout and it is showing this error everytime
im using 5.14.2 version10:01:14: Starting C:\Qt_codes\connecterQml\debug\connecterQml.exe ...
QQmlApplicationEngine failed to load component
qrc:/main.qml:86:17: TableViewColumn is not a type
QML debugging is enabled. Only use this in a safe environment.
10:01:14: C:\Qt_codes\connecterQml\debug\connecterQml.exe exited with code -1 -
@sanjay13 said in qml editable table creation:
TableViewColumn
This is part of the deprecated Qt Quick Controls 1 library. On the other hand you are using the more modern
TableView
from Qt Quick Controls 2. You can't mix them this way and the advice would be to avoid using the old, deprecated library altogether.