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. Issues porting code from QtQuick.Controls to Qt.labs.controls

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

Scheduled Pinned Locked Moved QML and Qt Quick
qmlqt.labs.control
4 Posts 3 Posters 1.2k Views
  • 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.
  • S Offline
    S Offline
    Smatcher
    wrote on 29 Apr 2016, 13:02 last edited by
    #1

    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"
                //ButtonGroup.group: grp // !!! This will crash !!!
                LabCtrl.ButtonGroup.group: grp // !!! This works !!!
            }
    
            RadioButton {
                text: "bye"
                //ButtonGroup.group: grp // !!! This will crash !!!
                LabCtrl.ButtonGroup.group: grp // !!! This works !!!
            }
        }
    
        Flickable {
           anchors.top: row.bottom
           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.

    1 Reply Last reply
    0
    • T Offline
      T Offline
      tmichals
      wrote on 29 Apr 2016, 14:05 last edited by tmichals
      #2
      This post is deleted!
      1 Reply Last reply
      0
      • J Offline
        J Offline
        jpnurmi
        wrote on 2 May 2016, 13:11 last edited by
        #3

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

        S 1 Reply Last reply 2 May 2016, 15:17
        0
        • J jpnurmi
          2 May 2016, 13:11

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

          S Offline
          S Offline
          Smatcher
          wrote on 2 May 2016, 15:17 last edited by
          #4

          @jpnurmi

          Done. Here is the link for reference https://bugreports.qt.io/browse/QTBUG-53137

          1 Reply Last reply
          1

          1/4

          29 Apr 2016, 13:02

          • Login

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