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. Bind a checkbox to a QVariantMap
Forum Updated to NodeBB v4.3 + New Features

Bind a checkbox to a QVariantMap

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
1 Posts 1 Posters 136 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.
  • A Offline
    A Offline
    aconnell
    wrote on last edited by
    #1

    I have a listview that generates a set of checkboxes where the modelData from the list is displayed as the label for the checkbox. What I'd really like to do, is have the modelData be a QVariantMap which has the text and the checked state, but I can't get this to work. I don't know how to get the key/value pairs from the QVariant map

    ---- this works but is a simple list ---
    ListView {
    id: associatedVariablesListView
    height: parent.height
    width: parent.width
    model: associatedVariableNames
    anchors.top: lruOptionsCombo.bottom

    delegate:  CheckBox {
        id: cbx
        onCheckedChanged: updateCharts(this, modelData)
        clip: false
        height: 35
        Text {
            font.pointSize: 8
            anchors.left: cbx.right
            anchors.verticalCenter: cbx.verticalCenter
            text: modelData
            color: foregroundColor
        }
    
    }
    

    }

    ---- this is what I want, but it doesn't work ---
    ListView {
    id: associatedVariablesListView
    height: parent.height
    width: parent.width
    model: associatedVariableNames
    anchors.top: lruOptionsCombo.bottom

    delegate:  CheckBox {
        id: cbx
        onCheckedChanged: updateCharts(this, modelData)
        clip: false
        height: 35
        checked: modelData.value        
        Text {
            font.pointSize: 8
            anchors.left: cbx.right
            anchors.verticalCenter: cbx.verticalCenter
            text: modelData.key
            color: foregroundColor
        }
    
    }
    

    }

    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