user214051
user214051

Reputation:

Qt invokeMethod with QString

I have a daemon running on DBus that offers service for launching applications. I want to pass two strings to this service API (appPath, appArgs). I have registered the service and the object path with DBus.

My service method gets called, but I do not receive the arguments properly () in my service. This is how I'm doing it from my adaptor class,

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

This is how my interface looks like.

"  <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"

How do I achieve this?

Upvotes: 2

Views: 784

Answers (1)

Juan E. Delgado
Juan E. Delgado

Reputation: 77

I use this to call methods with differents types of 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);

Upvotes: 1

Related Questions