2017-07-31 102 views
0

我需要添加一个组件在堆栈布局的特定位置,我不知道如何插入,下面是代码。QML - 如何在StackLayout中的任何位置插入一个项目?

import QtQuick 2.6 
import QtQuick.Controls 2.2 
import QtQuick.Layouts 1.3 

Component{ 
    id:comp 
    Rectangle{ 
     id:rect 
     anchors.fill:parent 
    } 
} 

StackLayout 
{ 
    id:stack 
    anchors.fill:parent 

    currentIndex:index //spin box will update this property 
} 

Button 
{ 
    id:insert 
    onClicked: 
    { 
     var res = comp.createObject(stack) // Should insert a rect at a position not at the end 
    } 
} 

回答

相关问题