Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/392.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何在QML弹出窗口中安排项目?_Javascript_Qt_Qml - Fatal编程技术网

Javascript 如何在QML弹出窗口中安排项目?

Javascript 如何在QML弹出窗口中安排项目?,javascript,qt,qml,Javascript,Qt,Qml,这就是我尝试过的。我希望弹出窗口矩形的内部矩形填充整个区域。左侧和顶部有一些间隙 Window { visible: true width: 1000 height: 1000 title: qsTr("Hello World") Rectangle { id: dot color:"blue"; radius: 100 height: 33

这就是我尝试过的。我希望弹出窗口矩形的内部矩形填充整个区域。左侧和顶部有一些间隙

Window
{
    visible: true
    width: 1000
    height: 1000
    title: qsTr("Hello World")


    Rectangle
    {
        id: dot

        color:"blue"; radius: 100
        height: 33
        width:  33

        MouseArea
        {
            anchors.fill: parent
            onClicked: popup.open()
        }
    }

    Popup
    {
        id: popup;
        width: 114
        height: 88
        x: 100; y: 45
        focus: true
        closePolicy: Popup.CloseOnEscape | Popup.CloseOnPressOutsideParent
       Rectangle
       {
           color: "red";
           anchors.fill: parent

           ColumnLayout
           {anchors.fill: parent
               Rectangle{ height: 30; width: 100; border.color: "black"}
               Rectangle{ height: 30; width: 100; border.color: "black"}
               Rectangle{ height: 30; width: 100; border.color: "black"}
           }
       }
    }

您需要注意
弹出窗口
填充
列布局间距

间隙是由弹出的
填充
造成的。。。如果您不希望填充
将其设置为0

但即使使用0
填充

您将在右侧看到间隙。因为弹出窗口的矩形继承了
弹出窗口的宽度
(114),但内部矩形设置为固定的
宽度
。。因此出现了14的差距

如果你能解决这个问题。。仍然需要考虑<代码>栏布局>代码>间距。默认情况下,这不是0,这可能会导致最后一个矩形延伸到弹出窗口的矩形下方,因此可以使用矩形的
剪辑

例如,此代码按预期绘制矩形

Popup
{
    id: popup;
    padding: 0
    width: 114
    height: 88
    x: 100; y: 45
    focus: true
    closePolicy: Popup.CloseOnEscape | Popup.CloseOnPressOutsideParent
   Rectangle
   {
       color: "red";
       anchors.fill: parent

       ColumnLayout
       {
           anchors.fill: parent
           Rectangle{ height:30; width: popup.width; border.color: "black"}
           Rectangle{ height: 30; width: popup.width; border.color: "black"}
           Rectangle{ height: 30; width: popup.width; border.color: "black"}
       }
   }
}

如果我想概括<代码>弹出< /代码>和<代码>栏布局< /代码>默认值,我会考虑使用<代码> Calistime<代码>,给出弹出窗口的矩形尺寸: 例如:

Popup
{
    id: popup;
    width: 114
    height: 29 * 3
    x: 100; y: 45
    focus: true
    closePolicy: Popup.CloseOnEscape | Popup.CloseOnPressOutsideParent
   Rectangle
   {
       color: "red";
       anchors.fill: parent

       ColumnLayout
       {
           anchors.fill: parent
            Repeater{
                id: repeater
                model: 3
                Rectangle{ height: (popup.contentItem.height - parent.spacing*repeater.count)/repeater.count; width: popup.contentItem.width; border.color: "black"}
            }
       }
   }
}

您需要注意
弹出窗口
填充
列布局间距

间隙是由弹出的
填充
造成的。。。如果您不希望填充
将其设置为0

但即使使用0
填充

您将在右侧看到间隙。因为弹出窗口的矩形继承了
弹出窗口的宽度
(114),但内部矩形设置为固定的
宽度
。。因此出现了14的差距

如果你能解决这个问题。。仍然需要考虑<代码>栏布局>代码>间距。默认情况下,这不是0,这可能会导致最后一个矩形延伸到弹出窗口的矩形下方,因此可以使用矩形的
剪辑

例如,此代码按预期绘制矩形

Popup
{
    id: popup;
    padding: 0
    width: 114
    height: 88
    x: 100; y: 45
    focus: true
    closePolicy: Popup.CloseOnEscape | Popup.CloseOnPressOutsideParent
   Rectangle
   {
       color: "red";
       anchors.fill: parent

       ColumnLayout
       {
           anchors.fill: parent
           Rectangle{ height:30; width: popup.width; border.color: "black"}
           Rectangle{ height: 30; width: popup.width; border.color: "black"}
           Rectangle{ height: 30; width: popup.width; border.color: "black"}
       }
   }
}

如果我想概括<代码>弹出< /代码>和<代码>栏布局< /代码>默认值,我会考虑使用<代码> Calistime<代码>,给出弹出窗口的矩形尺寸: 例如:

Popup
{
    id: popup;
    width: 114
    height: 29 * 3
    x: 100; y: 45
    focus: true
    closePolicy: Popup.CloseOnEscape | Popup.CloseOnPressOutsideParent
   Rectangle
   {
       color: "red";
       anchors.fill: parent

       ColumnLayout
       {
           anchors.fill: parent
            Repeater{
                id: repeater
                model: 3
                Rectangle{ height: (popup.contentItem.height - parent.spacing*repeater.count)/repeater.count; width: popup.contentItem.width; border.color: "black"}
            }
       }
   }
}