Popup QML Type

The base type of popup-like user interface controls. More...

Import Statement: import QtQuick.Controls 2.0
Since: Qt 5.7
Inherited By:

Drawer, Menu, and ToolTip

Properties

Signals

Methods

Detailed Description

Popup is the base type of popup-like user interface controls. It can be used with Window or ApplicationWindow.


  import QtQuick.Window 2.2
  import QtQuick.Controls 2.0

  Window {
      id: window
      width: 400
      height: 400
      visible: true

      Button {
          text: "Open"
          onClicked: popup.open()
      }

      Popup {
          id: popup
          x: 100
          y: 100
          width: 200
          height: 300
          modal: true
          focus: true
          closePolicy: Popup.CloseOnEscape | Popup.CloseOnPressOutsideParent
      }
  }

In order to ensure that a popup is displayed above other items in the scene, it is recommended to use ApplicationWindow. ApplicationWindow also provides background dimming effects.

See also Popup Controls.

Property Documentation

[read-only] activeFocus : bool

This property holds whether the popup has active focus.


[read-only] availableHeight : real

This property holds the height available after deducting vertical padding.

See also padding, topPadding, and bottomPadding.


[read-only] availableWidth : real

This property holds the width available after deducting horizontal padding.

See also padding, leftPadding, and rightPadding.


background : Item

This property holds the background item.

Note: If the background item has no explicit size specified, it automatically follows the popup's size. In most cases, there is no need to specify width or height for a background item.


bottomMargin : real

This property holds the bottom margin around the popup.

A popup with a negative bottom margin is not pushed within the bottom edge of the enclosing window. The default value is -1.

See also margins and topMargin.


bottomPadding : real

This property holds the bottom padding.

See also padding, topPadding, and availableHeight.


clip : bool

This property holds whether clipping is enabled. The default value is false.


closePolicy : enumeration

This property determines the circumstances under which the popup closes. The flags can be combined to allow several ways of closing the popup.

The available values are:

ConstantDescription
Popup.NoAutoCloseThe popup will only close when manually instructed to do so.
Popup.CloseOnPressOutsideThe popup will close when the mouse is pressed outside of it.
Popup.CloseOnPressOutsideParentThe popup will close when the mouse is pressed outside of its parent.
Popup.CloseOnReleaseOutsideThe popup will close when the mouse is released outside of it.
Popup.CloseOnReleaseOutsideParentThe popup will close when the mouse is released outside of its parent.
Popup.CloseOnEscapeThe popup will close when the escape key is pressed while the popup has active focus.

The default value is Popup.CloseOnEscape | Popup.CloseOnPressOutside.


contentChildren : list<Item>

This property holds the list of content children.

See also Item::children.


[default] contentData : list<Object>

This property holds the list of content data.

See also Item::data.


contentHeight : real

This property holds the content height. It is used for calculating the total implicit height of the Popup.

Note: If only a single item is used within the Popup, the implicit height of its contained item is used as the content height.


contentItem : Item

This property holds the content item of the popup.

The content item is the visual implementation of the popup. When the popup is made visible, the content item is automatically reparented to the overlay item of its application window.


contentWidth : real

This property holds the content width. It is used for calculating the total implicit width of the Popup.

Note: If only a single item is used within the Popup, the implicit width of its contained item is used as the content width.


dim : bool

This property holds whether the popup dims the background.

Unless explicitly set, this property follows the value of modal. To return to the default value, set this property to undefined.

See also modal.


enter : Transition

This property holds the transition that is applied to the content item when the popup is opened and enters the screen.


exit : Transition

This property holds the transition that is applied to the content item when the popup is closed and exits the screen.


focus : bool

This property holds whether the popup has focus. The default value is false.


font : font

This property holds the font currently set for the popup.


height : real

This property holds the height of the popup.


implicitHeight : real

This property holds the implicit height of the popup.


implicitWidth : real

This property holds the implicit width of the popup.


leftMargin : real

This property holds the left margin around the popup.

A popup with a negative left margin is not pushed within the left edge of the enclosing window. The default value is -1.

See also margins and rightMargin.


leftPadding : real

This property holds the left padding.

See also padding, rightPadding, and availableWidth.


locale : Locale

This property holds the locale of the popup.

See also LayoutMirroring.


margins : real

This property holds the default margins around the popup.

A popup with negative margins is not pushed within the bounds of the enclosing window. The default value is -1.

See also topMargin, leftMargin, rightMargin, and bottomMargin.


This property holds whether the popup is modal. The default value is false.


opacity : real

This property holds the opacity of the popup. The default value is 1.0.


padding : real

This property holds the default padding.

See also availableWidth, availableHeight, topPadding, leftPadding, rightPadding, and bottomPadding.


parent : Item

This property holds the parent item.


rightMargin : real

This property holds the right margin around the popup.

A popup with a negative right margin is not pushed within the right edge of the enclosing window. The default value is -1.

See also margins and leftMargin.


rightPadding : real

This property holds the right padding.

See also padding, leftPadding, and availableWidth.


scale : real

This property holds the scale factor of the popup. The default value is 1.0.


topMargin : real

This property holds the top margin around the popup.

A popup with a negative top margin is not pushed within the top edge of the enclosing window. The default value is -1.

See also margins and bottomMargin.


topPadding : real

This property holds the top padding.

See also padding, bottomPadding, and availableHeight.


transformOrigin : enumeration

This property holds the origin point for transformations in enter and exit transitions.

Nine transform origins are available, as shown in the image below. The default transform origin is Popup.Center.

See also enter, exit, and Item::transformOrigin.


visible : bool

This property holds whether the popup is visible. The default value is false.


width : real

This property holds the width of the popup.


x : real

This property holds the x-coordinate of the popup.


y : real

This property holds the y-coordinate of the popup.


z : real

This property holds the z-value of the popup. Z-value determines the stacking order of popups. The default z-value is 0.


Signal Documentation

void closed()

This signal is emitted when the popup is closed.

See also opened.


void opened()

This signal is emitted when the popup is opened.

See also closed.


Method Documentation

void close()

Closes the popup.


void forceActiveFocus(reason = Qt.OtherFocusReason)

Forces active focus on the popup with the given reason.

This method sets focus on the popup and ensures that all ancestor FocusScope objects in the object hierarchy are also given focus.

See also activeFocus and Qt::FocusReason.


void open()

Opens the popup.