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. qml editable table creation
Forum Updated to NodeBB v4.3 + New Features

qml editable table creation

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
2 Posts 2 Posters 273 Views
  • 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.
  • S Offline
    S Offline
    sanjay13
    wrote on last edited by
    #1

    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 version

    10: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

    B 1 Reply Last reply
    0
    • S sanjay13

      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 version

      10: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

      B Offline
      B Offline
      Bob64
      wrote on last edited by
      #2

      @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.

      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