如何使用 Qt Quick Controls 显示消息框? [英] How do I show a message box with Qt Quick Controls?
本文介绍了如何使用 Qt Quick Controls 显示消息框?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
当您希望使用 Qt Quick Controls 编写 QML 应用程序时,QMessageBox::information()
的等价物是什么?
What is the equivalent of QMessageBox::information()
when one wishes to write a QML application using Qt Quick Controls?
推荐答案
在 Qt 5.2 中有 MessageDialog:
In Qt 5.2 there is MessageDialog:
http://doc.qt.io/qt-5/qml-qtquick-dialogs-messagedialog.html
import QtQuick 2.2
import QtQuick.Dialogs 1.1
MessageDialog {
id: messageDialog
title: "May I have your attention please"
text: "It's so cool that you are using Qt Quick."
onAccepted: {
console.log("And of course you could only agree.")
Qt.quit()
}
Component.onCompleted: visible = true
}
这篇关于如何使用 Qt Quick Controls 显示消息框?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文