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 with CheckBox in header
Forum Updated to NodeBB v4.3 + New Features

TableView with CheckBox in header

Scheduled Pinned Locked Moved Solved QML and Qt Quick
qmltablviewcheckbox
6 Posts 2 Posters 4.3k 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.
  • P Offline
    P Offline
    PhTe
    wrote on 31 May 2016, 10:34 last edited by
    #1

    Hi,
    i have a QML TableView and would like to put a checkbox in the header row.
    Therefore i added a checkbox to the headerDelegate, but if i click on it, it does not change its state. Its always 'checked'.

    Has anyone an idea why i can not click on the checkbox.
    I also tried to a add a MouseArea to the header but it seems it will be ignored as well.

    My code looks like:

    TableView {
                id: tableView
                height: parent.height
                width: parent.width/2
    
    ...
    
    headerDelegate: Item {
                    height: 20
                    anchors.left: parent.left
                    anchors.right: parent.right
    
                    CheckBox {
                        anchors.centerIn: parent
                        id: activateAllEvents
                        checked: true
                        visible: styleData.column === 4 // Show only in the 4th column
                        activeFocusOnPress: true
                        text: ""
                    }
                }
    }
    
    1 Reply Last reply
    0
    • P Offline
      P Offline
      PhTe
      wrote on 6 Jun 2016, 09:35 last edited by
      #2

      Has noone an idea?

      M 1 Reply Last reply 6 Jun 2016, 18:52
      0
      • P PhTe
        6 Jun 2016, 09:35

        Has noone an idea?

        M Offline
        M Offline
        medyakovvit
        wrote on 6 Jun 2016, 18:52 last edited by
        #3

        @PhTe Are some signals emitted when you click checkbox (clicked(), pressed())?

        1 Reply Last reply
        0
        • P Offline
          P Offline
          PhTe
          wrote on 8 Jun 2016, 07:25 last edited by
          #4

          @medyakovvit No there are no signals emitted.

          I tried

          onClicked: {
              console.log("onClick");
          }
          onPressedChanged: {
              console.log("onPressedChanged");
          }
          onCheckedChanged: {
              console.log("onCheckedChanged");
          }
          

          but none of the functions are called if i click on the checkbox.

          M 1 Reply Last reply 8 Jun 2016, 09:42
          0
          • P PhTe
            8 Jun 2016, 07:25

            @medyakovvit No there are no signals emitted.

            I tried

            onClicked: {
                console.log("onClick");
            }
            onPressedChanged: {
                console.log("onPressedChanged");
            }
            onCheckedChanged: {
                console.log("onCheckedChanged");
            }
            

            but none of the functions are called if i click on the checkbox.

            M Offline
            M Offline
            medyakovvit
            wrote on 8 Jun 2016, 09:42 last edited by
            #5

            @PhTe, workaround:

            headerDelegate: Item {
                            height: 20
                            anchors.left: parent.left
                            anchors.right: parent.right
            
                            CheckBox {
                                id: activateAllEvents
                                anchors.centerIn: parent
                                
                                property bool myPressed: styleData.pressed
                                checked: true
                                visible: styleData.column === 4 // Show only in the 4th column
                                activeFocusOnPress: true
                                text: ""
                                onMyPressedChaged: {
                                    if(myPressed)
                                        checked = !checked;
                                }
                            }
                        }
            
            1 Reply Last reply
            1
            • P Offline
              P Offline
              PhTe
              wrote on 8 Jun 2016, 11:46 last edited by
              #6

              @medyakovvit Yeah, that woks. Thanks :)

              1 Reply Last reply
              0

              5/6

              8 Jun 2016, 09:42

              • Login

              • Login or register to search.
              5 out of 6
              • First post
                5/6
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • Users
              • Groups
              • Search
              • Get Qt Extensions
              • Unsolved