31. března 2009

Qt vs D-Bus: access to properties with dash in name

For properties without dash you should simple use:
QDBusInterface *iface = new QDBusInterface(service, path, interface, bus);
if (iface) {
if (iface->isValid()) {
int s = iface->property("property_name").toInt();
}
delete iface;
}

But if property name contains dash, you must use different approach:
QDBusInterface *iface = new QDBusInterface(service,
path,
"org.freedesktop.DBus.Properties",
bus);
if (iface) {
if (iface->isValid()) {
QDBusReply< QVariant> r = iface->call("Get",
interface,
"property-with-dash-in-name");
int s = r.value().toInt();
}
delete iface;
}


Service, path, bus, interface are same for both examples. See bug #20948 on bugs.freedesktop.org.

Žádné komentáře:

Okomentovat