aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/quick/doc/how-tos/how-to-cpp-enum-js/script.mjs
diff options
context:
space:
mode:
authorMitch Curtis <mitch.curtis@qt.io>2023-03-29 14:53:28 +0800
committerMitch Curtis <mitch.curtis@qt.io>2023-05-24 08:03:16 +0800
commitc504227e235885199717129e7c05addd728361fa (patch)
tree9c8dc0e735a18ac35dd5c0c9403f58c608a019ee /tests/auto/quick/doc/how-tos/how-to-cpp-enum-js/script.mjs
parentf2823f0a04b3c26daed51195af9a388810e30c02 (diff)
Doc: add how-to for using C++ enums in JavaScript
The best search result for "qt how do i expose a C++ enum to javascript" is currently a Qt Forum post, and the relevant information in our docs is hard to find within QJSEngine's page. Add a how-to to make it easier to find the answer. Task-number: QTBUG-109634 Pick-to: 6.5 Change-Id: Ia9c53c5d3826459655aa5b094c4d601b938ef3a3 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'tests/auto/quick/doc/how-tos/how-to-cpp-enum-js/script.mjs')
-rw-r--r--tests/auto/quick/doc/how-tos/how-to-cpp-enum-js/script.mjs13
1 files changed, 13 insertions, 0 deletions
diff --git a/tests/auto/quick/doc/how-tos/how-to-cpp-enum-js/script.mjs b/tests/auto/quick/doc/how-tos/how-to-cpp-enum-js/script.mjs
new file mode 100644
index 0000000000..de1e49a168
--- /dev/null
+++ b/tests/auto/quick/doc/how-tos/how-to-cpp-enum-js/script.mjs
@@ -0,0 +1,13 @@
+// Copyright (C) 2023 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+//! [file]
+export function backendStatusUpdate(backendStatus) {
+ if (backendStatus === Backend.Error) {
+ console.warn("Error!")
+ return
+ }
+
+ console.log("Backend loaded successfully")
+}
+//! [file]