MessageDialog QML Type
メッセージダイアログ。もっと見る...
Import Statement: | import QtQuick.Dialogs |
Since: | Qt 6.3 |
Inherits: |
プロパティ
- buttons : flags
- detailedText : string
- informativeText : string
- text : string
信号
- buttonClicked(QPlatformDialogHelper::StandardButton button, QPlatformDialogHelper::ButtonRole role)
詳細な説明
MessageDialog 型はメッセージダイアログのための QML API を提供します。
メッセージダイアログはユーザに情報を知らせたり、ユーザに質問をするために使用されます。メッセージダイアログは、ユーザに状況を知らせるためのプライマリtext 、アラートをさらに説明したり、ユーザに質問するためのinformative text 、ユーザが要求した場合にさらに多くのデータを提供するためのオプションdetailed text を表示します。メッセージ・ボックスは、ユーザーの応答を受け付けるための設定可能なセットbuttons を表示することもできます。
メッセージ・ダイアログを表示するには、MessageDialog のインスタンスを作成し、必要なプロパティを設定し、open ()を呼び出します。
MessageDialog { buttons: MessageDialog.Ok text: "The document has been modified." }
メッセージ・ダイアログを閉じるには、OK ボタンをクリックする必要があります。
ユーザーにイベントを警告するだけでなく、より手の込んだアプローチとして、ユーザーにそのイベントに対して何をすべきかを尋ねることもできます。その質問をinformative text プロパティに格納し、buttons プロパティにユーザーの応答として必要なボタンのセットを指定します。ボタンは、ビット単位のOR演算子を使って値を組み合わせて指定します。
MessageDialog { text: "The document has been modified." informativeText: "Do you want to save your changes?" buttons: MessageDialog.Ok | MessageDialog.Cancel onAccepted: document.save() }
利用可能性
ネイティブプラットフォームメッセージダイアログは、現在以下のプラットフォームで利用可能です:
- アンドロイド
- iOS
- macOS
Qt Quick ダイアログは、ネイティブな実装が利用できないプラットフォームでは、フォールバックとして の実装を使用します。Qt Quick
プロパティ Documentation
buttons : flags |
このプロパティは、メッセージダイアログで使用されるボタンの組み合わせを保持します。デフォルト値はMessageDialog.NoButton
です。
可能なフラグ
定数 | 説明 |
---|---|
MessageDialog.Ok | AcceptRole で定義された "OK "ボタン。 |
MessageDialog.Open | AcceptRole で定義された「開く」ボタン。 |
MessageDialog.Save | AcceptRole で定義された「保存」ボタン。 |
MessageDialog.Cancel | RejectRole で定義された「キャンセル」ボタン。 |
MessageDialog.Close | RejectRole で定義された「閉じる」ボタン。 |
MessageDialog.Discard | プラットフォームによって異なるが、DestructiveRole で定義された「破棄」または「保存しない」ボタン。 |
MessageDialog.Apply | ApplyRole で定義された「適用」ボタン。 |
MessageDialog.Reset | ResetRole で定義された「リセット」ボタン。 |
MessageDialog.RestoreDefaults | ResetRole で定義されている「デフォルトに戻す」ボタン。 |
MessageDialog.Help | HelpRole で定義された「ヘルプ」ボタン。 |
MessageDialog.SaveAll | AcceptRole で定義された「すべて保存」ボタン。 |
MessageDialog.Yes | YesRole で定義された「はい」ボタン。 |
MessageDialog.YesToAll | YesRole で定義された「Yes to All」ボタン。 |
MessageDialog.No | NoRole で定義された「いいえ」ボタン。 |
MessageDialog.NoToAll | NoRole で定義された「No to All」ボタン。 |
MessageDialog.Abort | RejectRole で定義された「中止」ボタン。 |
MessageDialog.Retry | AcceptRole で定義される「再試行」ボタン。 |
MessageDialog.Ignore | AcceptRole で定義された「無視」ボタン。 |
MessageDialog.NoButton | ダイアログにはボタンはありません。 |
buttonClicked()も参照 。
detailedText : string |
このプロパティは、詳細領域に表示されるテキストを保持します。
text およびinformativeText も参照 。
informativeText : string |
このプロパティは、メッセージの詳細な説明を提供する情報テキストを保持します。
インフォメーティブ・テキストは、text を拡張して、ユーザにより多くの情報を与えるために使用できます。
text およびdetailedTextも参照してください 。
text : string |
このプロパティは、メッセージ・ダイアログに表示されるテキストを保持します。
informativeText およびdetailedText も参照して ください。
シグナル・ドキュメント
buttonClicked(QPlatformDialogHelper::StandardButton button, QPlatformDialogHelper::ButtonRole role) |
このシグナルは、指定されたrole を持つbutton がクリックされたときに発せられます。
このシグナルにハンドラを与えることで、任意のカスタムボタンが押されたときに応答することができます。button 引数はどのボタンがクリックされたかを示し、role 引数はそのボタンの機能的な役割を示します。
MessageDialog { id: dialog text: qsTr("The document has been modified.") informativeText: qsTr("Do you want to save your changes?") buttons: MessageDialog.Ok | MessageDialog.Cancel onButtonClicked: function (button, role) { switch (button) { case MessageDialog.Ok: document.save() break; } } }
注: 対応するハンドラはonButtonClicked
です。
buttonsも参照してください 。
© 2025 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.