Options
All
  • Public
  • Public/Protected
  • All
Menu

The Dialog object is used to display a dialog to the user which can be filled with a variety of widgets.

The left-hand column of the dialog can only contain headings. If you call addHeading without specifying maxWidth = true, your heading will be placed in the left-hand column of the dialog.

All other widgets will be placed in the right-hand side column. When you add multiple instances of the same type of widget sequentially, they will be grouped into the same row unless you call addNewRow in between adding the widgets.

This type is an extension of the QDialog type from Qt.

since

1.9

Hierarchy

Index

Constructors

constructor

  • new Dialog(): Dialog
  • new Dialog(windowTitle: string): Dialog
  • Create a new Dialog object without assigning a title and using the default width and height of 450 pixels.

  • Create a new dialog object, customizing the title.

Properties

accepted

accepted: Signal<void>

Called when the dialog is closed via accept or the done method is called with Dialog.Accepted as its argument.

enabled

enabled: boolean

If false, the widget cannot be interacted with. Qt documentation: QWidget.enabled

finished

finished: Signal<number>

Called when the dialog is closed or the done method is called. The number value it provides is either Dialog.Accepted or Dialog.Rejected.

minimumHeight

minimumHeight: number

You can use this property to prevent the widget from being resized to a height below this amount.

minimumWidth

minimumWidth: number

You can use this property to prevent the widget from being resized to a width below this amount.

newRowMode

newRowMode: typeof SameWidgetRows | typeof ManualRows | typeof SingleWidgetRows

Controls the automatic widget placement behavior of the dialog. Defaults to SameWidgetRows

rejected

rejected: Signal<void>

Called when the dialog is closed via the X button, reject, or the done method is called with Dialog.Rejected as its argument.

styleSheet

styleSheet: string

Set this property to override the style sheet for this widget.

See https://doc.qt.io/qt-6/stylesheet.html and https://doc.qt.io/qt-6/stylesheet-examples.html for more information.

toolTip

toolTip: string

The toolTip displayed when the user mouses over this widget

visible

visible: boolean

Controls whether this widget is visible. When toggling this property, the dialog layout will automatically adjust itself based on the visible widgets. Qt documentation: QWidget.visible;

windowTitle

windowTitle: string

The title of your dialog.

Static Readonly Accepted

Accepted: typeof Accepted

The dialog was accepted. Value is 1.

Static Readonly ManualRows

ManualRows: typeof ManualRows

In this mode, the dialog will not add a new row unless you call addNewRow, addHeading or addSeparator.

Static Readonly Rejected

Rejected: typeof Rejected

The dialog was rejected. Value is 0.

Static Readonly SameWidgetRows

SameWidgetRows: typeof SameWidgetRows

The default row layout mode for Dialogs. In this mode, if you add multiple of the same type of widget in a row, (for instance by calling addButton twice in a row), the Dialog will automatically group them into the same row.

As soon as a differently typed widget is added, a new row will be added to the dialog. The exception to this rule is the widget created by addLabel(), which will be mixed with any other widget types when using this mode.

Static Readonly SingleWidgetRows

SingleWidgetRows: typeof SingleWidgetRows

In this mode, only one widget will be allowed in the right column. A new row will be added after each time you place a widget in the right column.

Methods

accept

  • accept(): void

addButton

  • Add a Qt.QPushButton widget to the dialog to allow the user to press a button that you can respond to the clicked signal of.

addCheckBox

  • addCheckBox(labelText: string, defaultValue: boolean): QCheckBox
  • Add a Qt.QCheckBox widget to the dialog to allow a user to toggle a boolean value.

addColorButton

  • Add a ColorButton widget that allows the user to pick a color.

addComboBox

  • addComboBox(labelText: string, values: string[]): QComboBox
  • Add a Qt.QComboBox widget (AKA a dropdown) allowing the user to pick between multiple pre-set values.

addFilePicker

  • addFilePicker(labelText?: string): FileEdit
  • Add a FileEdit widget with a button which opens a file picker dialog and displays the path in the dialog.

addHeading

  • addHeading(labelText: string, maxWidth?: boolean): QLabel
  • Add a heading to the dialog. A heading will always be the first widget in a row.

addImage

  • Adds an image widget that can display an image in a dialog.

addLabel

  • addLabel(labelText: string): QLabel
  • Add a label to the dialog. A label will always be the first widget in a row.

addNewRow

  • addNewRow(): void
  • Call this to force the next widget to go on a new row, even if it is the same type widget as the last one you added.

addNumberInput

  • Add a Qt.QSlider widget to the dialog to allow a user to type a numerical value or use up and down controls on the widget to manipulate the value. This can be used to enter integer or decimal values.

addSeparator

  • addSeparator(labelText?: string): QFrame
  • Adds a separator line with optional label to the dialog. Used to visually split up sections of the dialog.

addSlider

  • addSlider(labelText?: string): QSlider
  • Add a Qt.QSlider widget to the dialog to allow a user to slide a handle within a number range. This can only be used to enter integer-type values.

addTextEdit

  • addTextEdit(labelText?: string, defaultValue?: string): QTextEdit
  • Add a Qt.QTextEdit widget to the dialog to allow the user to edit multiple lines of text. Also allows display of rendered HTML by setting the Qt.QTextEdit.html property.

addTextInput

  • addTextInput(labelText?: string, defaultValue?: string): QLineEdit
  • Add a Qt.QLineEdit widget to the dialog to allow the user to enter a single line of text

clear

  • clear(): void
  • Erase all of the widgets that you have added to the dialog. Call this if you want to re-draw your dialog with a new configuration of widgets.

done

exec

  • Open the dialog, blocking your script until the Dialog has been accepted or rejected.

reject

  • reject(): void

show

  • show(): void
  • Show the dialog. Call this after you have added all of your desired widgets. This will not block your script until the dialog opens.

    To respond to the dialog closing, it is recommended to connect to the finished signal.

Generated using TypeDoc