Cannot make multiple buttons in CheckDelegate or RadioDelegate



  • I want to test CheckDelegate and RadioDelegate, however, when I directly use the following code from document, only the "Option 1" is showed. Cannot see "Option 2" and "Option 3". Am I doing something wrong?

    ListView {
        model: ["Option 1", "Option 2", "Option 3"]
        delegate: CheckDelegate {
            text: modelData
        }
    }
    
    ButtonGroup {
        id: buttonGroup
    }
    
    ListView {
        model: ["Option 1", "Option 2", "Option 3"]
        delegate: RadioDelegate {
            text: modelData
            checked: index == 0
            ButtonGroup.group: buttonGroup
        }
    }
    


  • Remember:
    a ListView is correctly shown only if it has a certain size.
    Add width and height to it and everything will be fine ;)
    e.g.

        ListView {
            width: 400
            height: 600
            model: ["Option 1", "Option 2", "Option 3"]
            delegate: CheckDelegate {
                text: modelData
            }
        }
    

Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.