2009-11-18 5 views
2

J'ai un démon sous DBus qui offre un service de lancement d'applications. Je veux passer deux chaînes à cette API de service (appPath, appArgs). J'ai enregistré le service et le chemin d'objet avec DBus.Qt invokeMethod avec QString

Ma méthode de service est appelée, mais je ne reçois pas les arguments correctement() dans mon service. Voici comment je le fais à partir de ma classe d'adaptateur,

call(QDBus::Block, QLatin1String("LaunchApp"), appPath, appArgs); 

Voici à quoi ressemble mon interface.

" <interface name=\"com.company.AppLauncher\" >\n" 
" <method name=\"LaunchApp\">\n" 
" <arg name=\"appPath\" type=\"s\" direction=\"in\"/>\n" 
" <arg name=\"appArgs\" type=\"s\" direction=\"in\"/>\n" 
" </method> \n" 

Comment puis-je y parvenir?

+0

Pouvez-vous expliquer de quelle façon vous ne recevez pas les arguments correctement? – rohanpm

Répondre

1

J'utilise ceci pour appeler des méthodes avec différents types d'arguments:

QString appPath("somepath"); 
QString appArgs("somargs"); 

QList<QVariant> argumentList; 
QVariant argument; 
argument.setValue(appPath); 
argumentList.append(argument); 
argument.setValue(appArgs); 
argumentList.append(argument); 

callWithArgumentList(QDBus::Block,"LaunchApp",argumentList); 
Questions connexes