A request for showing an alert, a confirmation, or a prompt dialog from within JavaScript to the user.More...
Import Statement: | import QtWebEngine 1.10 |
Since: | QtWebEngine 1.4 |
A JavaScriptDialogRequest is passed as an argument of theWebEngineView::javaScriptDialogRequested signal. The request is emitted if JavaScript on the page calls HTML5'sSimple Dialogs API, or in response to HTML5'sBeforeUnloadEvent. The type of a particular dialog can be checked with thetype property.
Theaccepted property of the request indicates whether the request is handled by the user code or the default dialog should be displayed. If you set theaccepted property totrue
, make sure to call eitherdialogAccept() ordialogReject() afterwards. The JavaScript call causing the request will be blocked until then.
The following code uses a custom dialog to handle the request:
WebEngineView {// ... onJavaScriptDialogRequested: function(request) { request.accepted=true; myDialog.request= request// keep the reference to the request myDialog.accept.connect(request.dialogAccept); myDialog.reject.connect(request.dialogReject); myDialog.visible=true; }// ...}
accepted :bool |
Indicates whether the JavaScript dialog request has been accepted by the signal handler.
If the property isfalse
after any signal handlers forWebEngineView::javaScriptDialogRequested have been executed, a default dialog will be shown. To prevent this, setrequest.accepted
totrue
.
The default isfalse
.
[read-only]defaultText :string |
The default prompt text, if the requested dialog is a prompt.
[read-only]message :string |
The message to be shown to the user.
[read-only]securityOrigin :url |
The URL of the security origin.
[read-only]title :string |
A default title for the dialog.
[read-only]type :enumeration |
Returns the type of the requested dialog box. For more information, see HTML5'sSimple Dialogs.
Constant | Description |
---|---|
JavaScriptDialogRequest.DialogTypeAlert | A JavaScript alert dialog. |
JavaScriptDialogRequest.DialogTypeConfirm | A JavaScript confirmation dialog. |
JavaScriptDialogRequest.DialogTypePrompt | A JavaScript prompt dialog. |
JavaScriptDialogRequest.DialogTypeBeforeUnload | The users should be asked if they want to leave the page. |
voiddialogAccept(stringtext) |
This function notifies the engine that the user accepted the dialog, providing thetext in case of a prompt message box.
© 2025 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of theGNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.
Qt Group includes The Qt Company Oy and its global subsidiaries and affiliates.