diff options
Diffstat (limited to 'src/gui/util/qdesktopservices.cpp')
-rw-r--r-- | src/gui/util/qdesktopservices.cpp | 28 |
1 files changed, 15 insertions, 13 deletions
diff --git a/src/gui/util/qdesktopservices.cpp b/src/gui/util/qdesktopservices.cpp index dfd190ddd0..b6eac91478 100644 --- a/src/gui/util/qdesktopservices.cpp +++ b/src/gui/util/qdesktopservices.cpp @@ -141,6 +141,10 @@ void QOpenUrlHandlerRegistry::handlerDestroyed(QObject *handler) same argument, and it will try to open the URL using the appropriate mechanism for the user's desktop environment. + Combined with platform specific settings, the schemes registered by the + openUrl() function can also be exposed to other applications, opening up + for application deep linking or a very basic URL-based IPC mechanism. + \note Since Qt 5, storageLocation() and displayName() are replaced by functionality provided by the QStandardPaths class. @@ -183,12 +187,7 @@ void QOpenUrlHandlerRegistry::handlerDestroyed(QObject *handler) \l{https://developer.apple.com/documentation/uikit/uiapplication/1622952-canopenurl}{canOpenURL(_:)}. For example, the following lines enable URLs with the HTTPS scheme: - \code - <key>LSApplicationQueriesSchemes</key> - <array> - <string>https</string> - </array> - \endcode + \snippet code/src_gui_util_qdesktopservices.cpp 3 \sa setUrlHandler() */ @@ -245,6 +244,14 @@ bool QDesktopServices::openUrl(const QUrl &url) The provided method must be implemented as a slot that only accepts a single QUrl argument. + To use this function for receiving data from other apps on iOS you also need to + add the custom scheme to the \c CFBundleURLSchemes list in your Info.plist file: + + \snippet code/src_gui_util_qdesktopservices.cpp 4 + + For more information, see the Apple Developer Documentation for + \l{https://developer.apple.com/documentation/uikit/core_app/allowing_apps_and_websites_to_link_to_your_content/communicating_with_other_apps_using_custom_urls?language=objc}{Communicating with Other Apps Using Custom URLs}. + If setUrlHandler() is used to set a new handler for a scheme which already has a handler, the existing handler is simply replaced with the new one. Since QDesktopServices does not take ownership of handlers, no objects are @@ -324,14 +331,9 @@ void QDesktopServices::unsetUrlHandler(const QString &scheme) wasn't called, while in Qt 5 it defaults to the name of the executable. Therefore, if you still need to access the Qt 4 path (for example for data migration to Qt 5), replace - \code - QDesktopServices::storageLocation(QDesktopServices::DataLocation) - \endcode + \snippet code/src_gui_util_qdesktopservices.cpp 5 with - \code - QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) + - "/data/organization/application" - \endcode + \snippet code/src_gui_util_qdesktopservices.cpp 6 (assuming an organization name and an application name were set). */ |