Sophie

Sophie

distrib > Mageia > 5 > i586 > media > core-release > by-pkgid > 50facae208d4a6f280e44a513b104320 > files > 1889

qt-mobility-doc-1.2.0-13.mga5.noarch.rpm

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en_US" lang="en_US">
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!-- servicebrowser.qdoc -->
  <title>Qt Mobility 1.2: Service Browser Example</title>
  <link rel="stylesheet" type="text/css" href="style/offline.css" />
</head>
<body>
<div class="header" id="qtdocheader">
  <div class="content"> 
    <a href="index.html" class="qtref"><span>QtMobility Reference Documentation</span></a>
  </div>
  <div class="breadcrumb toolblock">
    <ul>
      <li class="first"><a href="index.html">Home</a></li>
      <!--  Breadcrumbs go here -->
<li><a href="http://qt.nokia.com/doc/4.7/all-examples.html">Examples</a></li>
<li>Service Browser Example</li>
    </ul>
  </div>
</div>
<div class="content mainContent">
<div class="toc">
<h3><a name="toc">Contents</a></h3>
<ul>
<li class="level1"><a href="#servicebrowser-class-definition">ServiceBrowser Class Definition</a></li>
<li class="level1"><a href="#servicebrowser-class-implementation">ServiceBrowser Class Implementation</a></li>
<li class="level2"><a href="#invoking-attributes-an-example">Invoking attributes: an example</a></li>
</ul>
</div>
<h1 class="title">Service Browser Example</h1>
<span class="subtitle"></span>
<!-- $$$servicebrowser-description -->
<div class="descr"> <a name="details"></a>
<p>Files:</p>
<ul>
<li><a href="servicebrowser-servicebrowser-cpp.html">servicebrowser/servicebrowser.cpp</a></li>
<li><a href="servicebrowser-servicebrowser-h.html">servicebrowser/servicebrowser.h</a></li>
<li><a href="servicebrowser-main-cpp.html">servicebrowser/main.cpp</a></li>
<li><a href="servicebrowser-servicebrowser-pro.html">servicebrowser/servicebrowser.pro</a></li>
</ul>
<p>This example shows how to use the Service Framework to:</p>
<ul>
<li>Register and unregister services</li>
<li>Find available services</li>
<li>Find the interfaces that are implemented by a service</li>
<li>Look up the attributes for an interface implementation using the meta-object system</li>
<li>Set a default interface implementation</li>
</ul>
<p class="centerAlign"><img src="images/servicebrowser.png" alt="Screenshot of the Service Browser example" /></p><p>The application window is split into three panes.</p>
<p>The top-left pane shows all the services that are registered within the Service Framework. For this example, the <a href="filemanagerplugin.html">filemanagerplugin</a> and <a href="bluetoothtransferplugin.html">bluetoothtransferplugin</a> services included in the <tt>examples/</tt> directory have been registered, and so are visible in this pane.</p>
<p>The bottom-left pane shows the interfaces implemented by the service selected in the top-left pane. Each entry in this list shows:</p>
<ul>
<li>The name and version of the implemented interface</li>
<li>The service that provides this implementation (in brackets)</li>
<li>Whether the implementation is the default for its interface</li>
</ul>
<p>The right-hand pane shows the attributes of an interface implementation that are invokable through the Qt meta-object system. Such attributes include signals, slots, properties and methods marked with the <tt>Q_INVOKABLE</tt> macro. If the &quot;Selected implementation&quot; radio button is checked, this view shows the attributes of the selected implementation in the bottom-left pane; otherwise, it shows the attributes of the <i>default</i> implementation for the interface of the selected implementation.</p>
<a name="servicebrowser-class-definition"></a>
<h2>ServiceBrowser Class Definition</h2>
<p>The ServiceBrowser class inherits from <a href="http://qt.nokia.com/doc/4.7/qwidget.html">QWidget</a>. It has several slots for reloading the lists in the three information panes, and for changing the default implementation for an interface.</p>
<pre class="qml"> <span class="keyword">class</span> ServiceBrowser : <span class="keyword">public</span> <span class="type"><a href="http://qt.nokia.com/doc/4.7/qwidget.html">QWidget</a></span>
 {
     Q_OBJECT
 <span class="keyword">public</span>:
     ServiceBrowser(<span class="type"><a href="http://qt.nokia.com/doc/4.7/qwidget.html">QWidget</a></span> <span class="operator">*</span>parent <span class="operator">=</span> <span class="number">0</span><span class="operator">,</span> <span class="type"><a href="http://qt.nokia.com/doc/4.7/qt.html">Qt</a></span><span class="operator">::</span>WindowFlags flags <span class="operator">=</span> <span class="number">0</span>);
     <span class="operator">~</span>ServiceBrowser();

 <span class="keyword">private</span> <span class="keyword">slots</span>:
     <span class="type">void</span> currentInterfaceImplChanged(<span class="type"><a href="http://qt.nokia.com/doc/4.7/qlistwidgetitem.html">QListWidgetItem</a></span> <span class="operator">*</span>current<span class="operator">,</span> <span class="type"><a href="http://qt.nokia.com/doc/4.7/qlistwidgetitem.html">QListWidgetItem</a></span> <span class="operator">*</span>previous);
     <span class="type">void</span> reloadServicesList();
     <span class="type">void</span> reloadInterfaceImplementationsList();
     <span class="type">void</span> reloadAttributesList();
     <span class="type">void</span> setDefaultInterfaceImplementation();

 <span class="keyword">private</span>:
     ...
 };</pre>
<a name="servicebrowser-class-implementation"></a>
<h2>ServiceBrowser Class Implementation</h2>
<pre class="qml"> ServiceBrowser<span class="operator">::</span>ServiceBrowser(<span class="type"><a href="http://qt.nokia.com/doc/4.7/qwidget.html">QWidget</a></span> <span class="operator">*</span>parent<span class="operator">,</span> <span class="type"><a href="http://qt.nokia.com/doc/4.7/qt.html">Qt</a></span><span class="operator">::</span>WindowFlags flags)
     : <span class="type"><a href="http://qt.nokia.com/doc/4.7/qwidget.html">QWidget</a></span>(parent<span class="operator">,</span> flags)
 {
     serviceManager <span class="operator">=</span> <span class="keyword">new</span> <span class="type"><a href="qservicemanager.html">QServiceManager</a></span>(<span class="keyword">this</span>);
     systemManager <span class="operator">=</span> <span class="keyword">new</span> <span class="type"><a href="qservicemanager.html">QServiceManager</a></span>(<span class="type"><a href="qservice.html">QService</a></span><span class="operator">::</span>SystemScope);

     registerExampleServices();

     initWidgets();
     reloadServicesList();

     setWindowTitle(tr(<span class="string">&quot;Services Browser&quot;</span>));
 }</pre>
<p>The constructor registers the &quot;FileManagerService&quot;, &quot;BluetoothTransferService&quot; and &quot;NotesManagerServices&quot; services that are provided by the <a href="filemanagerplugin.html">filemanagerplugin</a> and <a href="bluetoothtransferplugin.html">bluetoothtransferplugin</a> projects in the <tt>examples/</tt> directory. It also calls <tt>reloadServicesList()</tt> to show these two newly registered services in the top-left pane.</p>
<pre class="qml"> <span class="type">void</span> ServiceBrowser<span class="operator">::</span>reloadServicesList()
 {
     servicesListWidget<span class="operator">-</span><span class="operator">&gt;</span>clear();

     <span class="type"><a href="http://qt.nokia.com/doc/4.7/qset.html">QSet</a></span><span class="operator">&lt;</span><span class="type"><a href="http://qt.nokia.com/doc/4.7/qstring.html">QString</a></span><span class="operator">&gt;</span> services;
     <span class="type"><a href="http://qt.nokia.com/doc/4.7/qlist.html">QList</a></span><span class="operator">&lt;</span><span class="type"><a href="qserviceinterfacedescriptor.html">QServiceInterfaceDescriptor</a></span><span class="operator">&gt;</span> descriptors <span class="operator">=</span> serviceManager<span class="operator">-</span><span class="operator">&gt;</span>findInterfaces();
     <span class="keyword">for</span> (<span class="type">int</span> i<span class="operator">=</span><span class="number">0</span>; i<span class="operator">&lt;</span>descriptors<span class="operator">.</span>count(); i<span class="operator">+</span><span class="operator">+</span>) {
         <span class="type"><a href="http://qt.nokia.com/doc/4.7/qstring.html">QString</a></span> service <span class="operator">=</span> descriptors<span class="operator">[</span>i<span class="operator">]</span><span class="operator">.</span>serviceName();

         <span class="keyword">if</span> (descriptors<span class="operator">[</span>i<span class="operator">]</span><span class="operator">.</span>scope() <span class="operator">=</span><span class="operator">=</span> <span class="type"><a href="qservice.html">QService</a></span><span class="operator">::</span>SystemScope)
             service <span class="operator">+</span><span class="operator">=</span> tr(<span class="string">&quot; (system)&quot;</span>);

         services <span class="operator">&lt;</span><span class="operator">&lt;</span> service;
     }</pre>
<p>When the services list in the top-left pane needs to be refreshed, we call <a href="qservicemanager.html#findServices">QServiceManager::findServices</a>() to get a <a href="http://qt.nokia.com/doc/4.7/qstringlist.html">QStringList</a> of all services that are currently registered with the service framework.</p>
<pre class="qml"> <span class="type">void</span> ServiceBrowser<span class="operator">::</span>reloadInterfaceImplementationsList()
 {
     ...
     ...
     <span class="type"><a href="http://qt.nokia.com/doc/4.7/qlist.html">QList</a></span><span class="operator">&lt;</span><span class="type"><a href="qserviceinterfacedescriptor.html">QServiceInterfaceDescriptor</a></span><span class="operator">&gt;</span> descriptors <span class="operator">=</span> manager<span class="operator">-</span><span class="operator">&gt;</span>findInterfaces(serviceName);

     attributesListWidget<span class="operator">-</span><span class="operator">&gt;</span>clear();
     interfacesListWidget<span class="operator">-</span><span class="operator">&gt;</span>clear();
     <span class="keyword">for</span> (<span class="type">int</span> i<span class="operator">=</span><span class="number">0</span>; i<span class="operator">&lt;</span>descriptors<span class="operator">.</span>count(); i<span class="operator">+</span><span class="operator">+</span>) {
         <span class="keyword">if</span> (descriptors<span class="operator">[</span>i<span class="operator">]</span><span class="operator">.</span>scope() <span class="operator">!</span><span class="operator">=</span> manager<span class="operator">-</span><span class="operator">&gt;</span>scope() <span class="operator">&amp;</span><span class="operator">&amp;</span> <span class="operator">!</span>serviceName<span class="operator">.</span>isEmpty())
             <span class="keyword">continue</span>;

         <span class="type"><a href="http://qt.nokia.com/doc/4.7/qstring.html">QString</a></span> text <span class="operator">=</span> <span class="type"><a href="http://qt.nokia.com/doc/4.7/qstring.html">QString</a></span>(<span class="string">&quot;%1 %2.%3&quot;</span>)
                 <span class="operator">.</span>arg(descriptors<span class="operator">[</span>i<span class="operator">]</span><span class="operator">.</span>interfaceName())
                 <span class="operator">.</span>arg(descriptors<span class="operator">[</span>i<span class="operator">]</span><span class="operator">.</span>majorVersion())
                 <span class="operator">.</span>arg(descriptors<span class="operator">[</span>i<span class="operator">]</span><span class="operator">.</span>minorVersion());

         <span class="type"><a href="qserviceinterfacedescriptor.html">QServiceInterfaceDescriptor</a></span> defaultInterfaceImpl
             <span class="operator">=</span> manager<span class="operator">-</span><span class="operator">&gt;</span>interfaceDefault(descriptors<span class="operator">[</span>i<span class="operator">]</span><span class="operator">.</span>interfaceName());

         <span class="keyword">if</span> (serviceName<span class="operator">.</span>isEmpty()) {
             text <span class="operator">+</span><span class="operator">=</span> <span class="string">&quot; (&quot;</span> <span class="operator">+</span> descriptors<span class="operator">[</span>i<span class="operator">]</span><span class="operator">.</span>serviceName() <span class="operator">+</span> <span class="string">&quot;)&quot;</span>;

             <span class="keyword">if</span> (descriptors<span class="operator">[</span>i<span class="operator">]</span><span class="operator">.</span>scope() <span class="operator">=</span><span class="operator">=</span> <span class="type"><a href="qservice.html">QService</a></span><span class="operator">::</span>SystemScope) {
                 text <span class="operator">+</span><span class="operator">=</span> tr(<span class="string">&quot; (system&quot;</span>);
                 defaultInterfaceImpl <span class="operator">=</span> systemManager<span class="operator">-</span><span class="operator">&gt;</span>interfaceDefault(descriptors<span class="operator">[</span>i<span class="operator">]</span><span class="operator">.</span>interfaceName());
                 <span class="keyword">if</span> (descriptors<span class="operator">[</span>i<span class="operator">]</span> <span class="operator">=</span><span class="operator">=</span> defaultInterfaceImpl)
                     text <span class="operator">+</span><span class="operator">=</span> tr(<span class="string">&quot; default)&quot;</span>);
                 <span class="keyword">else</span>
                     text <span class="operator">+</span><span class="operator">=</span> <span class="string">&quot;)&quot;</span>;
                 defaultInterfaceImpl <span class="operator">=</span> <span class="type"><a href="qserviceinterfacedescriptor.html">QServiceInterfaceDescriptor</a></span>();
             }
     ...
         }</pre>
<p>To create the list of interface implementations in the bottom-left pane, we call <a href="qservicemanager.html#findInterfaces">QServiceManager::findInterfaces</a>() to get a list of <a href="qserviceinterfacedescriptor.html">QServiceInterfaceDescriptor</a> objects. If a particular service has been selected in the top-left pane, we call <a href="qservicemanager.html#findInterfaces">QServiceManager::findInterfaces</a>() with the name of that service as the argument, so that it will only return the interface implementations provided by that service. Otherwise, it is called with no argument to retrieve a list of all implementations provided by all registered services.</p>
<p>The example maps each entry in the interface implementations list to its corresponding <a href="qserviceinterfacedescriptor.html">QServiceInterfaceDescriptor</a> object using the <a href="http://qt.nokia.com/doc/4.7/qlistwidgetitem.html#setData">QListWidgetItem::setData</a>() method.</p>
<p>Note how we also call QServiceManager::defaultServiceInterface() to determine whether an interface implementation is the default for that interface.</p>
<pre class="qml"> <span class="type">void</span> ServiceBrowser<span class="operator">::</span>reloadAttributesList()
 {
     <span class="type"><a href="http://qt.nokia.com/doc/4.7/qlistwidgetitem.html">QListWidgetItem</a></span> <span class="operator">*</span>item <span class="operator">=</span> interfacesListWidget<span class="operator">-</span><span class="operator">&gt;</span>currentItem();
     <span class="keyword">if</span> (<span class="operator">!</span>item)
         <span class="keyword">return</span>;

     <span class="type"><a href="qserviceinterfacedescriptor.html">QServiceInterfaceDescriptor</a></span> selectedImpl <span class="operator">=</span>
             item<span class="operator">-</span><span class="operator">&gt;</span>data(<span class="type"><a href="http://qt.nokia.com/doc/4.7/qt.html">Qt</a></span><span class="operator">::</span>UserRole)<span class="operator">.</span>value<span class="operator">&lt;</span><span class="type"><a href="qserviceinterfacedescriptor.html">QServiceInterfaceDescriptor</a></span><span class="operator">&gt;</span>();

     <span class="type"><a href="http://qt.nokia.com/doc/4.7/qobject.html">QObject</a></span> <span class="operator">*</span>implementationRef;
     <span class="keyword">if</span> (selectedImplRadioButton<span class="operator">-</span><span class="operator">&gt;</span>isChecked())
         implementationRef <span class="operator">=</span> serviceManager<span class="operator">-</span><span class="operator">&gt;</span>loadInterface(selectedImpl<span class="operator">,</span> <span class="number">0</span><span class="operator">,</span> <span class="number">0</span>);
     <span class="keyword">else</span>
         implementationRef <span class="operator">=</span> serviceManager<span class="operator">-</span><span class="operator">&gt;</span>loadInterface(selectedImpl<span class="operator">.</span>interfaceName()<span class="operator">,</span> <span class="number">0</span><span class="operator">,</span> <span class="number">0</span>);

     ...</pre>
<p>The <tt>reloadAttributesList()</tt> method creates the list in the right-hand pane that shows the attributes of an interface implementation that can be invoked through the Qt meta-object system.</p>
<p><a href="qservicemanager.html#loadInterface">QServiceManager::loadInterface</a>() is called to get an instance of the identified interface implementation. This method finds the corresponding service plugin and returns the <a href="http://qt.nokia.com/doc/4.7/qobject.html">QObject</a> instance provided by the service plugin's <a href="qserviceplugininterface.html#createInstance">QServicePluginInterface::createInstance</a>() method.</p>
<pre class="qml">     ...
     <span class="keyword">const</span> <span class="type"><a href="http://qt.nokia.com/doc/4.7/qmetaobject.html">QMetaObject</a></span> <span class="operator">*</span>metaObject <span class="operator">=</span> implementationRef<span class="operator">-</span><span class="operator">&gt;</span>metaObject();
     attributesGroup<span class="operator">-</span><span class="operator">&gt;</span>setTitle(tr(<span class="string">&quot;Invokable attributes for %1 class&quot;</span>)
             <span class="operator">.</span>arg(<span class="type"><a href="http://qt.nokia.com/doc/4.7/qstring.html">QString</a></span>(metaObject<span class="operator">-</span><span class="operator">&gt;</span>className())));
     <span class="keyword">for</span> (<span class="type">int</span> i<span class="operator">=</span><span class="number">0</span>; i<span class="operator">&lt;</span>metaObject<span class="operator">-</span><span class="operator">&gt;</span>methodCount(); i<span class="operator">+</span><span class="operator">+</span>) {
         <span class="type"><a href="http://qt.nokia.com/doc/4.7/qmetamethod.html">QMetaMethod</a></span> method <span class="operator">=</span> metaObject<span class="operator">-</span><span class="operator">&gt;</span>method(i);
         attributesListWidget<span class="operator">-</span><span class="operator">&gt;</span>addItem(<span class="string">&quot;[METHOD] &quot;</span> <span class="operator">+</span> <span class="type"><a href="http://qt.nokia.com/doc/4.7/qstring.html">QString</a></span>(method<span class="operator">.</span>signature()));
     }
     <span class="keyword">for</span> (<span class="type">int</span> i<span class="operator">=</span><span class="number">0</span>; i<span class="operator">&lt;</span>metaObject<span class="operator">-</span><span class="operator">&gt;</span>propertyCount(); i<span class="operator">+</span><span class="operator">+</span>) {
         <span class="type"><a href="http://qt.nokia.com/doc/4.7/qmetaproperty.html">QMetaProperty</a></span> property <span class="operator">=</span> metaObject<span class="operator">-</span><span class="operator">&gt;</span>property(i);
         attributesListWidget<span class="operator">-</span><span class="operator">&gt;</span>addItem(<span class="string">&quot;[PROPERTY] &quot;</span> <span class="operator">+</span> <span class="type"><a href="http://qt.nokia.com/doc/4.7/qstring.html">QString</a></span>(property<span class="operator">.</span>name()));
     }
 }</pre>
<p>Call <a href="http://qt.nokia.com/doc/4.7/qobject.html#metaObject">QObject::metaObject</a>() on the implementation instance to get a <a href="http://qt.nokia.com/doc/4.7/qmetaobject.html">QMetaObject</a> instance that reveals the dynamically invokable attributes for the instance. These attributes include properties, signals, slots, and methods marked with the <a href="http://qt.nokia.com/doc/4.7/qobject.html#Q_INVOKABLE">Q_INVOKABLE</a> macro. Call <a href="http://qt.nokia.com/doc/4.7/qmetaobject.html#method">QMetaObject::method</a>() to get information about a signal, slot or invokable method, and <a href="http://qt.nokia.com/doc/4.7/qmetaobject.html#property">QMetaObject::property</a>() to access a property of the instance.</p>
<p>When you know the name of the method you wish to invoke, call QMetaObject::invoke() or <a href="http://qt.nokia.com/doc/4.7/qmetamethod.html#invoke">QMetaMethod::invoke</a>() to invoke it dynamically. Similarly, <a href="http://qt.nokia.com/doc/4.7/qmetaproperty.html#read">QMetaProperty::read</a>() and <a href="http://qt.nokia.com/doc/4.7/qmetaproperty.html#write">QMetaProperty::write</a>() can be used to read and modify the value of a property.</p>
<a name="invoking-attributes-an-example"></a>
<h3>Invoking attributes: an example</h3>
<p>Here is an example of invoking attributes on an implementation, using the <a href="filemanagerplugin.html">FileManagerPlugin</a> that is shown in the Service Browser.</p>
<p>The <a href="filemanagerplugin.html">FileManagerPlugin</a> provides a service called &quot;FileManagerService&quot; in its <tt>filemanagerplugin.xml</tt> service definition. When FileManagerPlugin::createInstance() is called, if the com.nokia.qt.examples.FileStorage interface is requested, it returns an instance of the FileManagerStorage class. The FileManagerStorage class is defined like this:</p>
<pre class="qml"> <span class="keyword">class</span> FileManagerStorage : <span class="keyword">public</span> <span class="type"><a href="http://qt.nokia.com/doc/4.7/qobject.html">QObject</a></span>
 {
     Q_OBJECT
     Q_PROPERTY(<span class="type"><a href="http://qt.nokia.com/doc/4.7/qstring.html">QString</a></span> workingDirectory READ workingDirectory WRITE setWorkingDirectory)

 <span class="keyword">public</span>:
     FileManagerStorage(<span class="type"><a href="http://qt.nokia.com/doc/4.7/qobject.html">QObject</a></span> <span class="operator">*</span>parent <span class="operator">=</span> <span class="number">0</span>);

     <span class="type">void</span> setWorkingDirectory(<span class="keyword">const</span> <span class="type"><a href="http://qt.nokia.com/doc/4.7/qstring.html">QString</a></span> <span class="operator">&amp;</span>path);
     <span class="type"><a href="http://qt.nokia.com/doc/4.7/qstring.html">QString</a></span> workingDirectory() <span class="keyword">const</span>;

 <span class="keyword">signals</span>:
     <span class="type">void</span> workingDirectoryChanged(<span class="keyword">const</span> <span class="type"><a href="http://qt.nokia.com/doc/4.7/qstring.html">QString</a></span> <span class="operator">&amp;</span>newDir);

 <span class="keyword">public</span> <span class="keyword">slots</span>:
     <span class="type">void</span> copyFile(<span class="keyword">const</span> <span class="type"><a href="http://qt.nokia.com/doc/4.7/qstring.html">QString</a></span> <span class="operator">&amp;</span>currentPath<span class="operator">,</span> <span class="keyword">const</span> <span class="type"><a href="http://qt.nokia.com/doc/4.7/qstring.html">QString</a></span> <span class="operator">&amp;</span>newPath);

 <span class="keyword">private</span>:
     <span class="type"><a href="http://qt.nokia.com/doc/4.7/qstring.html">QString</a></span> directory;
 };</pre>
<p>So if, in the ServiceBrowser application, we select the com.nokia.qt.examples.FileStorage implementation provided by FileManagerService, the browser would display all the dynamically invokable attributes of the FileManagerStorage class:</p>
<p class="centerAlign"><img src="images/servicebrowser-attributes.png" alt="" /></p><p>As you can see, the FileManagerStorage::workingDirectory property, the FileManagerStorage::copyFile() slot and the FileManagerStorage::workingDirectoryChanged() signal are all listed. (The destroyed(), deleteLater() and _q_reregisterTimers() attributes are inherited from the <a href="http://qt.nokia.com/doc/4.7/qobject.html">QObject</a> parent.)</p>
<p>To invoke the <tt>copyFile()</tt> slot, for example:</p>
<pre class="cpp"> <span class="type"><a href="http://qt.nokia.com/doc/4.7/qobject.html">QObject</a></span> <span class="operator">*</span>interfaceImpl <span class="operator">=</span> <span class="type"><a href="qservicemanager.html">QServiceManager</a></span><span class="operator">::</span>loadInterface(<span class="string">&quot;com.nokia.qt.examples.FileStorage&quot;</span><span class="operator">,</span> <span class="number">0</span><span class="operator">,</span> <span class="number">0</span>);
 <span class="type"><a href="http://qt.nokia.com/doc/4.7/qmetaobject.html">QMetaObject</a></span><span class="operator">::</span>invokeMethod(interfaceImpl<span class="operator">,</span> <span class="string">&quot;copyFile&quot;</span><span class="operator">,</span>
                           Q_ARG(<span class="type"><a href="http://qt.nokia.com/doc/4.7/qstring.html">QString</a></span><span class="operator">,</span> <span class="string">&quot;path/to/file.txt&quot;</span>)<span class="operator">,</span>
                           Q_ARG(<span class="type"><a href="http://qt.nokia.com/doc/4.7/qstring.html">QString</a></span><span class="operator">,</span> <span class="string">&quot;new/path/to/file.txt&quot;</span>));</pre>
<p>Of course, the <a href="qservicemanager.html#loadInterface">QServiceManager::loadInterface</a>() call here assumes the FileManagerStorage implementation is the default for the com.nokia.qt.examples.FileStorage interface. Otherwise, it would have to pass a <a href="qserviceinterfacedescriptor.html">QServiceInterfaceDescriptor</a> object to <a href="qservicemanager.html#loadInterface">QServiceManager::loadInterface</a>() instead of just the interface name to ensure the correct implementation is loaded.</p>
</div>
<!-- @@@servicebrowser -->
  <div class="ft">
    <span></span>
  </div>
</div> 
<div class="footer">
  <p>
     <acronym title="Copyright">&copy;</acronym> 2008-2011 Nokia Corporation and/or its
     subsidiaries. Nokia, Qt and their respective logos are trademarks of Nokia Corporation 
     in Finland and/or other countries worldwide.</p>
  <p>
     All other trademarks are property of their respective owners. <a title="Privacy Policy"
     href="http://qt.nokia.com/about/privacy-policy">Privacy Policy</a></p>
  <br />
  <p>
    Licensees holding valid Qt Commercial licenses may use this document in accordance with the    Qt Commercial License Agreement provided with the Software or, alternatively, in accordance    with the terms contained in a written agreement between you and Nokia.</p>
  <p>
    Alternatively, this document may be used under the terms of the <a href="http://www.gnu.org/licenses/fdl.html">GNU
    Free Documentation License version 1.3</a>
    as published by the Free Software Foundation.</p>
</div>
</body>
</html>