Learn what Felgo offers to help your business succeed. Start your free evaluation today! Felgo for Your Business

InputDialog

Global object for displaying standard user interaction dialogs. More...

Import Statement: import Felgo 4.0
Inherits:

Item

Properties

Methods

  • bool close()
  • Dialog confirm(Window window, string title, function callback, bool allowCancel)
  • Dialog inputTextMultiLine(Window window, string text, string placeholder, function callback, bool allowCancel)
  • Dialog inputTextSingleLine(Window window, string text, string placeholder, function callback, bool allowCancel)

Detailed Description

This is a convenience wrapper around the Dialog component to get input from the user. It is a global object, and can be used without creating additional QML objects.

InputDialog can be used to display text to the user and display one or two possible action buttons, and also to display a text input field.

As an alternative to the QML based InputDialog, the NativeDialog type may be used to invoke a native system dialog.

Confirm Dialog

To display a message and one or two action buttons, confirm() method can be used:

 Button {
   id: confirmBtn
   text: "Confirm Dialog"
   onClicked: InputDialog.confirm(app, "Confirm this action?", function(ok) {
     if(ok) {
       confirmBtn.text = "Confirmed!"
     }
   })
 }

Single and Multi-Line Text Input

To get single-line text input from the user, inputTextSingleLine() can be used:

 Button {
   id: inputBtn
   text: "Input Text Dialog"
   onClicked: InputDialog.inputTextSingleLine(app,
                                              "What do you think?", //message text
                                              "Input here",         //placeholder text
                                              function(ok, text) {
                                                if(ok) {
                                                  inputBtn.text = "Input: " + text
                                                }
                                              })
 }

To show a multi-line text input, use inputTextMultiLine() instead.

Advanced Usage

All three methods in InputDialog, confirm, inputTextSingleLine and inputTextMultiLine return the created Dialog object, which can be used to change properties of the dialog.

For example, the Dialog::negativeAction can be set to false, so only a positive action button will be displayed.

Also, the currentDialog property will return the currently shown Dialog object, if any.

Property Documentation

currentDialog : Dialog

The currently shown Dialog object, if any.


Method Documentation

bool close()

Closes the currently visible Dialog. Returns true if a dialog was currently visible.


Dialog confirm(Window window, string title, function callback, bool allowCancel)

Shows a confirm dialog with "Ok" and "Cancel" buttons and the specified title. To change the possible action buttons, use the returned Dialog object.

The window parameter should be a reference to the root QML Window, or in many cases the App object. If it is not specified, the dialog will not work.

The callback function will be called once one of the buttons was clicked. The first parameter of the callback will be a bool value that is true, if the positive action was clicked.

The last parameter allowCancel is optional and allows to disable the "Cancel" button of the dialog that will be shown. By default the setting is true, which shows both the "Ok" and "Cancel" buttons of the dialog.

Returns the Dialog item if it has been opened, and no InputDialog was already opened before the call, otherwise returns the previously opened Dialog.

Note: Only one InputDialog can be shown at a time. If a dialog is currently visible, nothing happens and this dialog is returned.


Dialog inputTextMultiLine(Window window, string text, string placeholder, function callback, bool allowCancel)

Shows a dialog with "Ok" and "Cancel" buttons, the specified text and an AppTextEdit item for multi-line text input. To change the possible action buttons, use the returned Dialog object.

The window parameter should be a reference to the root QML Window, or in many cases the App object. If it is not specified, the dialog will not work.

The callback function will be called once one of the buttons was clicked. The first parameter of the callback will be a bool value that is true, if the positive action was clicked. The second parameter of the callback will be a string containing the entered text.

The last parameter allowCancel is optional and allows to disable the "Cancel" button of the dialog that will be shown. By default the setting is true, which shows both the "Ok" and "Cancel" buttons of the dialog.

Returns the Dialog item if it has been opened, and no InputDialog was already opened before the call, otherwise returns the previously opened Dialog.

Note: Only one InputDialog can be shown at a time. If a dialog is currently visible, nothing happens and this dialog is returned.


Dialog inputTextSingleLine(Window window, string text, string placeholder, function callback, bool allowCancel)

Shows a dialog with "Ok" and "Cancel" buttons, the specified text and an AppTextInput item for single-line text input. To change the possible action buttons, use the returned Dialog object.

The window parameter should be a reference to the root QML Window, or in many cases the App object. If it is not specified, the dialog will not work.

The callback function will be called once one of the buttons was clicked. The first parameter of the callback will be a bool value that is true, if the positive action was clicked. The second parameter of the callback will be a string containing the entered text.

The last parameter allowCancel is optional and allows to disable the "Cancel" button of the dialog that will be shown. By default the setting is true, which shows both the "Ok" and "Cancel" buttons of the dialog.

Returns the Dialog item if it has been opened, and no InputDialog was already opened before the call, otherwise returns the previously opened Dialog.

Note: Only one InputDialog can be shown at a time. If a dialog is currently visible, nothing happens and this dialog is returned.


Qt_Technology_Partner_RGB_475 Qt_Service_Partner_RGB_475_padded