Important: Please read the Qt Code of Conduct -

Issues porting code from QtQuick.Controls to Qt.labs.controls

  • Hello everyone.

    I am currently trying to port some code from Quick Controls to the new lab controls.
    As suggested by the documentation I made a Qml module (MyControls) wrapping either the old controls or the new controls

    This works for most types, however, I encountered a crash with the ScrollBar and ButtonGroup attached properties
    Here is some minimalist code illustrating the issue (the lines causing a crash are commented out)

    import QtQuick 2.5
    import QtQuick.Window 2.2
    import QtQuick.Dialogs 1.2
    import MyControls 1.0
    import Qt.labs.controls 1.0 as LabCtrl
    Window {
        title: qsTr("Hello World")
        width: 640
        height: 480
        visible: true
        ButtonGroup {
            id: grp
        Row {
            id: row
            RadioButton {
                text: "hello"
                // grp // !!! This will crash !!!
       grp // !!! This works !!!
            RadioButton {
                text: "bye"
                // grp // !!! This will crash !!!
       grp // !!! This works !!!
        Flickable {
           width: 200
           height: 100
           contentWidth: 200
           contentHeight: 200
           clip: true
           //LabCtrl.ScrollBar.vertical: ScrollBar{} // !!! This will crash !!!
           //LabCtrl.ScrollBar.vertical: LabCtrl.ScrollBar{} // !!! This will crash !!!
           Rectangle {
             width: 200
             height: 200
             gradient: Gradient {
               GradientStop {position: 0.0; color: "red"}
               GradientStop {position: 0.5; color: "green"}
               GradientStop {position: 1.0; color: "blue"}

    In the provided example the MyControls module just wraps RadioButton, ButtonGroup and ScrollBar. The qml files are just

    import Qt.labs.controls 1.0
    RadioButton {}
    import Qt.labs.controls 1.0
    ButtonGroup {}
    import Qt.labs.controls 1.0
    ScrollBar {}

    Has anyone faced a similar issue ? (I couldn't find any bug report for this specific crash)
    Having to import Qt.labs.controls to refer to the attached property of the initial control type seems to defeat the purpose of using a wrapper module (and doesn't work for the ScrollBar type).
    What is the best practice in this situation ?

    Stepping in the Qt code I noticed that the crash occurs inside the function QQmlObjectCreator::setPropertyBinding()
    The code fails to resolve the attached type and uses the null pointer to QQmlType anyway.
    Qt crashes instead of printing useful debug information.

    I haven't submitted a bug report yet. I will do it when I have more information on this issue.

  • This post is deleted!

  • Hi, sounds like a bug in the QML engine. Please report a bug. Thanks!

  • @jpnurmi

    Done. Here is the link for reference

Log in to reply