0

I want to change dynamicaly type of qml Item without re-creation. In this example window transforms into popup window and question is how to transform it to qml Item.

ApplicationWindow {
title: qsTr("Hello World")
width: 640
height: 480


Window {
    id: myWindow
    height: 300
    width: 300
    visible: true

    MouseArea {
        anchors.fill: parent
        onDoubleClicked: myWindow.flags = Qt.Popup
    }
}}
Kirill
  • 21
  • 1
  • So the title is about re-parenting, the body is bout changing types dynamically and the code is about something that doesn't make any sense... – dtech Oct 04 '16 at 16:29

2 Answers2

0

What are you trying to achieve?

You must understand that when you "transform" your Window into a popup Window, the actual type of your object does not change. You only set a flag, which happen to give your window a popup behavior. As to dynamically change the type of a QML object, I don't think it is even possible, and I don't see the point of it.

  • Yoann, I definitely understand the thing that is done in my example. But the question was how to do it without using any flag. – Kirill Sep 25 '14 at 10:48
0

When I want to make a 'pupup', I use something like that

Rectangle{

id:picker
visible:false
function find_superparent( child_object) {
     var fparent;
     fparent=child_object.parent;
     while(fparent.parent) fparent= fparent.parent;
     return fparent;
    }
Component.onCompleted: picker.parent=find_superparent(picker)

... }

and, when I want to show the popup picker.visible=true

I use this function (find_superparent) in dynamic component creation/destruction too...

this method works... I don't know if exists a better way ...