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. TableView HeaderDelegate CheckBox can't be checked
Qt 6.11 is out! See what's new in the release blog

TableView HeaderDelegate CheckBox can't be checked

Scheduled Pinned Locked Moved Solved QML and Qt Quick
2 Posts 1 Posters 1.9k 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.
  • G Offline
    G Offline
    Galbarad
    wrote on last edited by
    #1

    Hi all
    I have small problem with headerDelegate
    CheckBox than I placed at header can't be checked
    even MouseAria can't be clicked on header
    looks like something catch mouse action
    but I see that CheckBox changed when button pressed
    so I have no idea ((
    thanks for any help

    import QtQuick 2.2
    import QtQuick.Controls 1.4
    import QtQuick.Controls 2.0
       
     TableView {
            id: tvMain
            parent: svMain
    
            anchors.fill: parent
            frameVisible: false
            sortIndicatorVisible: true
            model: mainModel
            headerDelegate: aldHeader
    
            TableViewColumn {
                id: tvcDeployment
                title: dict.getStringByCode("Deployment")
                role: "d"
                movable: false
                delegate: aldJira
                width: 100
            }
    
            // more columns
    
            rowDelegate: Rectangle {
                height: 30
                color: styleData.selected ? "skyblue" : (styleData.row % 2 == 0 ? "whitesmoke" : "white")
            }
    
    
            Component {
                id: aldHeader
    
                Rectangle {
                    id: rHeader
                    height: 30
                    color: "lightsteelblue"
                    border.color: "lightgrey"
                    border.width: 1
    
                    MouseArea {
                        id: maHeader
                        anchors.fill: parent
                        z: 100
                        onClicked: {
                            // following line never appear in console
                            console.log("maHeader.onClicked", styleData.column, styleData.value);
                        }
                    }
    
                    Text {
                        id: tHeader
                        anchors.centerIn: parent
                        text: styleData.value
                    }
                    
                    CheckBox {
                        id: cbHeader
                        anchors.centerIn: parent
    
                        onClicked: {
                            // following line never appear in console
                            console.log("changeStateForAll", styleData.column, styleData.value);                        
                        }
                    }
    
                    Component.onCompleted: {
                        console.log("tHeader.onCompleted", tHeader.width, width, styleData.column, styleData.value);
                        if ((styleData.column === 10) || (styleData.column === 9) || (styleData.column === 8)) {
                            cbHeader.visible = true;
                            tHeader.visible = false;
                        } else {
                            cbHeader.visible = false;
                            tHeader.visible = true;
                        }
                    }
                }
            }
        }
    
    1 Reply Last reply
    0
    • G Offline
      G Offline
      Galbarad
      wrote on last edited by
      #2

      I should train my google skills))
      https://forum.qt.io/topic/67707/tableview-with-checkbox-in-header/5
      it's work

      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