Overview | Package | Class | Tree | Deprecated | Index | Help
Qt Jambi Home |
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.trolltech.qt.gui
Class QDesktopServices

    java.lang.Object
      com.trolltech.qt.QSignalEmitter
          com.trolltech.qt.QtJambiObject
              com.trolltech.qt.gui.QDesktopServices

All Implemented Interfaces:
  QtJambiInterface

    public class QDesktopServices

extends QtJambiObject

The `QDesktopServices` class provides methods for accessing common desktop services.

Many desktop environments provide services that can be used by applications to perform common tasks, such as opening a web page, in a way that is both consistent and takes into account the user's application preferences.

This class contains functions that provide simple interfaces to these services that indicate whether they succeeded or failed.

The `openUrl` function is used to open files located at arbitrary URLs in external applications. For URLs that correspond to resources on the local filing system (where the URL scheme is "file"), a suitable application will be used to open the file; otherwise, a web browser will be used to fetch and display the file.

The user's desktop settings control whether certain executable file types are opened for browsing, or if they are executed instead. Some desktop environments are configured to prevent users from executing files obtained from non-local URLs, or to ask the user's permission before doing so.

### URL Handlers

The behavior of the `openUrl` function can be customized for individual URL schemes to allow applications to override the default handling behavior for certain types of URLs.

The dispatch mechanism allows only one custom handler to be used for each URL scheme; this is set using the setUrlHandler() function. Each handler is implemented as a slot which accepts only a single `QUrl` argument.

The existing handlers for each scheme can be removed with the `unsetUrlHandler` function. This returns the handling behavior for the given scheme to the default behavior.

This system makes it easy to implement a help system, for example. Help could be provided in labels and text browsers using help://myapplication/mytopic URLs, and by registering a handler it becomes possible to display the help text inside the application:

        class MyHelpHandler : public QObject
        {
            Q_OBJECT
        public:
            ...
        public slots:
            void showHelp(const QUrl &url);
        };

        QDesktopServices::setUrlHandler("help", helpInstance, "showHelp");

If inside the handler you decide that you can't open the requested URL, you can just call QDesktopServices::openUrl() again with the same argument, and it will try to open the URL using the appropriate mechanism for the user's desktop environment.

See Also:
  `QSystemTrayIcon`, `QProcess`

Nested Class Summary

Nested classes/interfaces inherited from class com.trolltech.qt.QSignalEmitter
`QSignalEmitter.AbstractSignal, QSignalEmitter.Signal0, QSignalEmitter.Signal1<A>, QSignalEmitter.Signal2<A,B>, QSignalEmitter.Signal3<A,B,C>, QSignalEmitter.Signal4<A,B,C,D>, QSignalEmitter.Signal5<A,B,C,D,E>, QSignalEmitter.Signal6<A,B,C,D,E,F>, QSignalEmitter.Signal7<A,B,C,D,E,F,G>, QSignalEmitter.Signal8<A,B,C,D,E,F,G,H>, QSignalEmitter.Signal9<A,B,C,D,E,F,G,H,I>`

Method Summary
`static QDesktopServices` | `fromNativePointer(QNativePointer nativePointer)` This function returns the QDesktopServices instance pointed to by nativePointer
`static boolean` | `openUrl(QUrl url)` Opens the given `url` in the appropriate web browser for the user's desktop environment, and returns true if successful; otherwise returns false.
`static void` | `unsetUrlHandler(java.lang.String scheme)` Removes a previously set url handler for the specified `scheme`.

Methods inherited from class com.trolltech.qt.QtJambiObject
`dispose, disposed, finalize, reassignNativeResources, tr, tr, tr`

Methods inherited from class com.trolltech.qt.QSignalEmitter
`blockSignals, disconnect, disconnect, signalsBlocked, signalSender, thread`

Methods inherited from class java.lang.Object
`clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Methods inherited from interface com.trolltech.qt.QtJambiInterface
`disableGarbageCollection, nativeId, nativePointer, reenableGarbageCollection, setJavaOwnership`

Method Detail

### openUrl

    public static boolean openUrl(QUrl url)

  Opens the given `url` in the appropriate web browser for the user's desktop environment, and returns true if successful; otherwise returns false.

  If the URL is a reference to a local file (i.e. the URL scheme is "file") then it will be opened with a suitable application instead of a web browser.

  If a `mailto` URL is specified, the user's e-mail client will be used to open a composer window containing the options specified in the URL, similar to the way `mailto` links are handled by a web browser.

  For example, the following URL contains a recipient (`user@foo.com`), a subject (`Test`), and a message body (`Just a test`):

          mailto:user@foo.com?subject=Test&body=Just a test

  Warning: Although many e-mail clients can send attachments and are Unicode-aware, the user may have configured their client without these features. Also, certain e-mail clients (e.g., Lotus Notes) have problems with long URLs.

  See Also:
    `setUrlHandler`

### unsetUrlHandler

    public static void unsetUrlHandler(java.lang.String scheme)

  Removes a previously set url handler for the specified `scheme`.

### fromNativePointer

    public static QDesktopServices fromNativePointer(QNativePointer nativePointer)

  This function returns the QDesktopServices instance pointed to by nativePointer

  Parameters:
    `nativePointer` - the QNativePointer of which object should be returned.

Overview | Package | Class | Tree | Deprecated | Index | Help
Qt Jambi Home |
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD