为什么当我打开Dialog时它会禁用所有qml项目

时间:2018-06-16 05:51:30

标签: qt qml qtquick2 drawer

我的qt快速应用程序中有一个自定义对话框,当我点击一个按钮打开它时,我会得到以下错误:

  QQuickItem :: stackBefore:无法在0x6d4bd6e220之前堆叠,这必须是兄弟

发生此错误后,main.qml页面上的所有qml项目都将禁用并且不起作用,并且不会与宽度鼠标进行交互。

main.qml

onClicked: {     
                var c= userPorfileCom.createObject(mainWindow);
                 c.open();
            }

Component{
    id:userPorfileCom
    UserProfilePage{
        id: userProfilePage
    }
}

UserProfilePage.qml

JooyaDialog{
id: root
IranSanseFontLoader{
    id: fl
}
onVisibleChanged: {
    if(visible)
    {
        up.getProfile();
    }
}
header: ToolBar{
    id: tbheader
    Material.primary: "white"
    Material.elevation:1
    RowLayout{
        anchors.fill: parent
        ToolButton{
            contentItem: Image {
                source: "/images/close.png"
                fillMode: Image.Pad
                horizontalAlignment: Image.AlignHCenter
                verticalAlignment: Image.AlignVCenter
            }
            onClicked: {
                close();
            }
        }
    }
}

signal profileHasChanged;
UserProfile{
    id: up
    name: tfName.text
    lastName: tfLastName.text
    gender: cbxGender.currentIndex==0
    email: tfEmail.text
    phoneNumber: tfMobile.text
    onProfileChanged: {
        loginManager.getUserInfo();
    }
    onMessageChanged: {
        showMessage(message);
    }
    onIsProcessingChanged: {
        console.log("progr in user info");
        bipi.visible=isProcessing;
    }
}

title: qsTr("ویرایش اطلاعات کاربری")
rootWidth:mainWindow.width
rootHeight: mainWindow.height
contentHeight:rootHeight/2

font{
    family: fl.name
    pixelSize: 18
    bold: true
}
//================================================
Flickable{
    id: flickable
    contentHeight: mainClm.implicitHeight+100
    flickableDirection: Flickable.AutoFlickIfNeeded
    clip: true
    anchors.fill: parent
    Pane{
        anchors.fill:parent

        Material.accent: Material.Pink
        ColumnLayout{
            id: mainClm
            anchors.fill: parent

            JooyaTextField{
                id: tfName
                placeholderText: "نام"
                Layout.fillWidth: true
                text: up.name
            }
            JooyaTextField{
                id: tfLastName
                placeholderText: "نام خانوادگی"
                Layout.fillWidth: true
                text: up.lastName
            }
            ComboBox {
                id: cbxGender
                model: ["مرد", "زن"]
                anchors.horizontalCenter: parent.horizontalCenter
                Layout.fillWidth: true
                currentIndex:
                {
                    if(up.gender)
                    {
                        return 0// "مرد"
                    }
                    else
                    {
                        return 1//"زن"
                    }
                }
            }
            JooyaTextField{
                id: tfMobile
                placeholderText: "شماره موبایل"
                Layout.fillWidth: true
                text: up.phoneNumber
                inputMethodHints: Qt.ImhDigitsOnly
            }
            JooyaTextField{
                id: tfEmail
                placeholderText: "ایمیل"
                Layout.fillWidth: true
                text: up.email
            }
            JooyaButton{
                id: btnSave
                text: "ذخیره"
                Layout.fillWidth: true
                highlighted: true
                onClicked: {
                    up.saveProfile();
                }
            }

        }
    }

    ScrollBar.vertical: ScrollBar{
        width: 3
    }

}
ProgressIndicator{
    id: bipi
}
}

1 个答案:

答案 0 :(得分:0)

如果标签焦点链中有两个项目,而不是兄弟姐妹则不会工作, 意味着标签焦点链中的内容必须具有相同的直接父级。

http://doc.qt.io/qt-5/qquickitem.html#stackBefore