首页 > 解决方案 > QML 中的 QMessageBox::aboutQt 等价物是什么?

问题描述

QMessageBox::aboutQtQML 中是否可以使用等效项?我没有在QtQuick.Dialogs模块中找到任何合适的东西(https://doc.qt.io/qt-5/qtquickdialogs-index.html)。

标签: qtqmlqtquick2qtquickcontrols2

解决方案


QMessageBox::about与 QML最接近的匹配MessageDialog设置如下:

import QtQuick 2.2
import QtQuick.Dialogs 1.1

MessageDialog {
    title: "Your title"
    icon: StandardIcon.Information
    text: "Your text"
    standardButtons: StandardButton.Ok
    Component.onCompleted: visible = true
}

至于QMessageBox::aboutQt,根据this topic,在Qt论坛中,没有QML等价物,最好调用qApp->aboutQt

阅读文档似乎没有关于 QML 的 Qt。

从 C++ 类调用标准 qApp->aboutQt 可能更好。


推荐阅读