Dialog

Search for usage in LXR

Inheritance diagram for Dialog:

Properties

real absoluteMaximumHeight
 
real absoluteMaximumWidth
 
listTAction customFooterActions
 
alias dialogChildren
 
alias dialogData
 
bool flatFooterButtons
 
Component footerLeadingComponent
 
Component footerTrailingComponent
 
real maximumHeight
 
real maximumWidth
 
real preferredHeight
 
real preferredWidth
 
bool showCloseButton
 

Public Member Functions

void customFooterButton (T.Action action)
 
void standardButton (button)
 

Detailed Description

Popup dialog that is used for short tasks and user interaction.

Dialog consists of three components: the header, the content, and the footer.

By default, the header is a heading with text specified by the title property.

By default, the footer consists of a row of buttons specified by the standardButtons and customFooterActions properties.

The implicitHeight and implicitWidth of the dialog contentItem is the primary hint used for the dialog size. The dialog will be the minimum size required for the header, footer and content unless it is larger than maximumHeight and maximumWidth. Use preferredHeight and preferredWidth in order to manually specify a size for the dialog.

If the content height exceeds the maximum height of the dialog, the dialog's contents will become scrollable.

If the contentItem is a ListView, the dialog will take care of the necessary scrollbars and scrolling behaviour. Do not attempt to nest ListViews (it must be the top level item), as the scrolling behaviour will not be handled. Use ListView's header and footer instead.

Example for a selection dialog:

import QtQuick
import QtQuick.Layouts
import QtQuick.Controls as QQC2
import org.kde.kirigami as Kirigami
Kirigami.Dialog {
title: i18n("Dialog")
padding: 0
preferredWidth: Kirigami.Units.gridUnit * 16
standardButtons: Kirigami.Dialog.Ok | Kirigami.Dialog.Cancel
onAccepted: console.log("OK button pressed")
onRejected: console.log("Rejected")
ColumnLayout {
spacing: 0
Repeater {
model: 5
delegate: QQC2.CheckDelegate {
topPadding: Kirigami.Units.smallSpacing * 2
bottomPadding: Kirigami.Units.smallSpacing * 2
Layout.fillWidth: true
text: modelData
}
}
}
}
Popup dialog that is used for short tasks and user interaction.
Definition Dialog.qml:110
real preferredWidth
This property holds the preferred width of the dialog.
Definition Dialog.qml:183

Example with scrolling (ListView scrolling behaviour is handled by the Dialog):

import QtQuick
import QtQuick.Layouts
import QtQuick.Controls as QQC2
import org.kde.kirigami as Kirigami
Kirigami.Dialog {
id: scrollableDialog
title: i18n("Select Number")
ListView {
id: listView
// hints for the dialog dimensions
implicitWidth: Kirigami.Units.gridUnit * 16
implicitHeight: Kirigami.Units.gridUnit * 16
model: 100
delegate: QQC2.RadioDelegate {
topPadding: Kirigami.Units.smallSpacing * 2
bottomPadding: Kirigami.Units.smallSpacing * 2
implicitWidth: listView.width
text: modelData
}
}
}

There are also sub-components of the Dialog that target specific usecases, and can reduce boilerplate code if used:

See also
PromptDialog
MenuDialog

Definition at line 110 of file Dialog.qml.

Property Documentation

◆ absoluteMaximumHeight

real Dialog::absoluteMaximumHeight
read

This property sets the absolute maximum height the dialog can have.

The height restriction is solely applied on the content, so if the maximum height given is not larger than the height of the header and footer, it will be ignored.

This is the window height, subtracted by largeSpacing on both the top and bottom.

Remarks
This property is read-only

Definition at line 138 of file Dialog.qml.

◆ absoluteMaximumWidth

real Dialog::absoluteMaximumWidth
read

This property holds the absolute maximum width the dialog can have.

By default, it is the window width, subtracted by largeSpacing on both the top and bottom.

Remarks
This property is read-only

Definition at line 146 of file Dialog.qml.

◆ customFooterActions

listTAction Dialog::customFooterActions
read

This property holds the custom actions displayed in the footer.

Example usage:

import QtQuick
import org.kde.kirigami as Kirigami
Kirigami.PromptDialog {
id: dialog
title: i18n("Confirm Playback")
subtitle: i18n("Are you sure you want to play this song? It's really loud!")
standardButtons: Kirigami.Dialog.Cancel
Kirigami.Action {
text: i18n("Play")
icon.name: "media-playback-start"
onTriggered: {
//...
dialog.close();
}
}
]
}
listTAction customFooterActions
This property holds the custom actions displayed in the footer.
Definition Dialog.qml:229
QString i18n(const char *text, const TYPE &arg...)
See also
org::kde::kirigami::Action

Definition at line 229 of file Dialog.qml.

◆ dialogChildren

alias Dialog::dialogChildren
read

This property holds the content items of the dialog.

The initial height and width of the dialog is calculated from the implicitWidth and implicitHeight of the content.

Definition at line 126 of file Dialog.qml.

◆ dialogData

alias Dialog::dialogData
read

This property holds the dialog's contents; includes Items and QtObjects.

Remarks
This is the default property

Definition at line 117 of file Dialog.qml.

◆ flatFooterButtons

bool Dialog::flatFooterButtons
read

This property sets whether the footer button style should be flat.

Definition at line 199 of file Dialog.qml.

◆ footerLeadingComponent

Component Dialog::footerLeadingComponent
read

This property holds the component to the left of the footer buttons.

Definition at line 187 of file Dialog.qml.

◆ footerTrailingComponent

Component Dialog::footerTrailingComponent
read

his property holds the component to the right of the footer buttons.

Definition at line 191 of file Dialog.qml.

◆ maximumHeight

real Dialog::maximumHeight
read

This property holds the maximum height the dialog can have (including the header and footer).

The height restriction is solely enforced on the content, so if the maximum height given is not larger than the height of the header and footer, it will be ignored.

By default, this is absoluteMaximumHeight.

Definition at line 157 of file Dialog.qml.

◆ maximumWidth

real Dialog::maximumWidth
read

This property holds the maximum width the dialog can have.

By default, this is absoluteMaximumWidth.

Definition at line 163 of file Dialog.qml.

◆ preferredHeight

real Dialog::preferredHeight
read

This property holds the preferred height of the dialog.

The content will receive a hint for how tall it should be to have the dialog to be this height.

If the content, header or footer require more space, then the height of the dialog will expand to the necessary amount of space.

Definition at line 173 of file Dialog.qml.

◆ preferredWidth

real Dialog::preferredWidth
read

This property holds the preferred width of the dialog.

The content will receive a hint for how wide it should be to have the dialog be this wide.

If the content, header or footer require more space, then the width of the dialog will expand to the necessary amount of space.

Definition at line 183 of file Dialog.qml.

◆ showCloseButton

bool Dialog::showCloseButton
read

This property sets whether to show the close button in the header.

Definition at line 195 of file Dialog.qml.


The documentation for this class was generated from the following file:
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sat Dec 21 2024 16:56:52 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.