Dialog QML Type

Popup dialog with standard buttons and a title, used for short-term interaction with the user. 更多...

import 語句: import QtQuick.Controls
繼承: Popup

特性

信號

方法

詳細描述

A dialog is a popup mostly used for short-term tasks and brief communications with the user. Similarly to ApplicationWindow and Page , Dialog is organized into three sections: header , contentItem ,和 footer .

By default, Dialogs have focus .

Dialog Title and Buttons

Dialog's title is displayed by a style-specific title bar that is assigned as a dialog header 在默認情況下。

Dialog's standard buttons are managed by a DialogButtonBox that is assigned as a dialog footer by default. The dialog's standardButtons property is forwarded to the respective property of the button box. Furthermore, the accepted () 和 rejected () signals of the button box are connected to the respective signals in Dialog.

Dialog {
    id: dialog
    title: "Title"
    standardButtons: Dialog.Ok | Dialog.Cancel
    onAccepted: console.log("Ok clicked")
    onRejected: console.log("Cancel clicked")
}
					

A modal dialog blocks input to other content beneath the dialog. When a modal dialog is opened, the user must finish interacting with the dialog and close it before they can access any other content in the same window.

Dialog {
    id: dialog
    modal: true
    standardButtons: Dialog.Ok
}
					

非模態對話框

A modeless dialog is a dialog that operates independently of other content around the dialog. When a modeless dialog is opened, the user is allowed to interact with both the dialog and the other content in the same window.

Dialog {
    id: dialog
    modal: false
    standardButtons: Dialog.Ok
}
					

另請參閱 DialogButtonBox and 彈齣控件 .

特性文檔編製

This property holds the dialog footer item. The footer item is positioned to the bottom, and resized to the width of the dialog. The default value is null .

注意: Assigning a DialogButtonBox as a dialog footer automatically connects its accepted () 和 rejected () signals to the respective signals in Dialog.

注意: Assigning a DialogButtonBox , ToolBar ,或 TabBar as a dialog footer automatically sets the respective DialogButtonBox::position , ToolBar::position ,或 TabBar::position 特性到 Footer .

另請參閱 header .

header : Item

This property holds the dialog header item. The header item is positioned to the top, and resized to the width of the dialog. The default value is null .

注意: Assigning a DialogButtonBox as a dialog header automatically connects its accepted () 和 rejected () signals to the respective signals in Dialog.

注意: Assigning a DialogButtonBox , ToolBar ,或 TabBar as a dialog header automatically sets the respective DialogButtonBox::position , ToolBar::position ,或 TabBar::position 特性到 .

另請參閱 footer .

[read-only, since QtQuick.Controls 2.5 (Qt 5.12)] implicitFooterHeight : real

This property holds the implicit footer height.

值等於 footer && footer.visible ? footer.implicitHeight : 0 .

該特性在 QtQuick.Controls 2.5 (Qt 5.12) 引入。

另請參閱 implicitFooterWidth and implicitHeaderHeight .

[read-only, since QtQuick.Controls 2.5 (Qt 5.12)] implicitFooterWidth : real

This property holds the implicit footer width.

值等於 footer && footer.visible ? footer.implicitWidth : 0 .

該特性在 QtQuick.Controls 2.5 (Qt 5.12) 引入。

另請參閱 implicitFooterHeight and implicitHeaderWidth .

[read-only, since QtQuick.Controls 2.5 (Qt 5.12)] implicitHeaderHeight : real

This property holds the implicit header height.

值等於 header && header.visible ? header.implicitHeight : 0 .

該特性在 QtQuick.Controls 2.5 (Qt 5.12) 引入。

另請參閱 implicitHeaderWidth and implicitFooterHeight .

[read-only, since QtQuick.Controls 2.5 (Qt 5.12)] implicitHeaderWidth : real

This property holds the implicit header width.

值等於 header && header.visible ? header.implicitWidth : 0 .

該特性在 QtQuick.Controls 2.5 (Qt 5.12) 引入。

另請參閱 implicitHeaderHeight and implicitFooterWidth .

[since QtQuick.Controls 2.3 (Qt 5.10)] result : int

This property holds the result code.

Standard result codes:

常量 描述
Dialog.Accepted The dialog was accepted.
Dialog.Rejected The dialog was rejected.

該特性在 QtQuick.Controls 2.3 (Qt 5.10) 引入。

另請參閱 accept (), reject (),和 done ().

standardButtons : enumeration

This property holds a combination of standard buttons that are used by the dialog.

Dialog {
    id: dialog
    title: "Title"
    standardButtons: Dialog.Ok | Dialog.Cancel
    onAccepted: console.log("Ok clicked")
    onRejected: console.log("Cancel clicked")
}
													

The buttons will be positioned in the appropriate order for the user's platform.

Possible flags:

常量 描述
Dialog.Ok An "OK" button defined with the AcceptRole .
Dialog.Open An "Open" button defined with the AcceptRole .
Dialog.Save A "Save" button defined with the AcceptRole .
Dialog.Cancel A "Cancel" button defined with the RejectRole .
Dialog.Close A "Close" button defined with the RejectRole .
Dialog.Discard A "Discard" or "Don't Save" button, depending on the platform, defined with the DestructiveRole .
Dialog.Apply An "Apply" button defined with the ApplyRole .
Dialog.Reset A "Reset" button defined with the ResetRole .
Dialog.RestoreDefaults A "Restore Defaults" button defined with the ResetRole .
Dialog.Help A "Help" button defined with the HelpRole .
Dialog.SaveAll A "Save All" button defined with the AcceptRole .
Dialog.Yes A "Yes" button defined with the YesRole .
Dialog.YesToAll A "Yes to All" button defined with the YesRole .
Dialog.No A "No" button defined with the NoRole .
Dialog.NoToAll A "No to All" button defined with the NoRole .
Dialog.Abort An "Abort" button defined with the RejectRole .
Dialog.Retry A "Retry" button defined with the AcceptRole .
Dialog.Ignore An "Ignore" button defined with the AcceptRole .
Dialog.NoButton 無效按鈕。

另請參閱 DialogButtonBox .

title : string

This property holds the dialog title.

The title is displayed in the dialog header.

Dialog {
    title: qsTr("About")
    Label {
        text: "Lorem ipsum..."
    }
}
														

信號文檔編製

accepted ()

This signal is emitted when the dialog has been accepted either interactively or by calling accept ().

注意: This signal is not emitted when closing the dialog with close () or setting visible to false .

注意: 相應處理程序是 onAccepted .

另請參閱 rejected ().

[since QtQuick.Controls 2.3 (Qt 5.10)] applied ()

此信號發射,當 Dialog.Apply standard button is clicked.

注意: 相應處理程序是 onApplied .

This signal was introduced in QtQuick.Controls 2.3 (Qt 5.10).

另請參閱 discarded () 和 reset ().

[since QtQuick.Controls 2.3 (Qt 5.10)] discarded ()

此信號發射,當 Dialog.Discard standard button is clicked.

注意: 相應處理程序是 onDiscarded .

This signal was introduced in QtQuick.Controls 2.3 (Qt 5.10).

另請參閱 reset () 和 applied ().

[since QtQuick.Controls 2.3 (Qt 5.10)] helpRequested ()

此信號發射,當 Dialog.Help standard button is clicked.

注意: 相應處理程序是 onHelpRequested .

This signal was introduced in QtQuick.Controls 2.3 (Qt 5.10).

另請參閱 accepted () 和 rejected ().

rejected ()

This signal is emitted when the dialog has been rejected either interactively or by calling reject ().

注意: This signal is not emitted when closing the dialog with close () or setting visible to false .

注意: 相應處理程序是 onRejected .

另請參閱 accepted ().

[since QtQuick.Controls 2.3 (Qt 5.10)] reset ()

此信號發射,當 Dialog.Reset standard button is clicked.

注意: 相應處理程序是 onReset .

This signal was introduced in QtQuick.Controls 2.3 (Qt 5.10).

另請參閱 discarded () 和 applied ().


方法文檔編製

void accept ()

Emits the accepted () signal and closes the dialog.

另請參閱 reject () 和 done ().

[since QtQuick.Controls 2.3 (Qt 5.10)] void done ( int result )

  1. 設置 result .
  2. Emits accepted () 或 rejected () depending on whether the result is Dialog.Accepted or Dialog.Rejected ,分彆。
  3. Emits closed ().

This method was introduced in QtQuick.Controls 2.3 (Qt 5.10).

另請參閱 accept (), reject (),和 result .

void reject ()

Emits the rejected () signal and closes the dialog.

另請參閱 accept () 和 done ().

[since QtQuick.Controls 2.3 (Qt 5.10)] AbstractButton standardButton ( StandardButton button )

Returns the specified standard button ,或 null if it does not exist.

This method was introduced in QtQuick.Controls 2.3 (Qt 5.10).

另請參閱 standardButtons .

版權所有  © 2014-2026 樂數軟件    

工業和信息化部: 粵ICP備14079481號-1