首页 > 解决方案 > qml对话框删除确定按钮

问题描述

我想在没有 ok 按钮的 qml 中创建一个自定义对话框。这是我的代码:

Dialog {
    id: DialogId
    title: appName
}

当对话框打开时,有一个确定按钮。我正在使用 QtQuick.Dialogs 1.2

标签: qtdialogqml

解决方案


属性standardButtons控件的按钮在您的对话框中。

默认值为StandardButton.Ok

如果您不需要任何按钮,则需要重新实现contentItem

例如:

contentItem: Rectangle {
    color: "lightskyblue"
    implicitWidth: 400
    implicitHeight: 100
    Text {
        text: "Hello blue sky!"
        color: "navy"
        anchors.centerIn: parent
    }
}

推荐阅读