2012/7/7 Thiago Macieira <thiago.macie...@intel.com>: > On sábado, 7 de julho de 2012 09.22.50, Lucas Betschart wrote: >> Thats my code: >> >> bool QUbuntuOne::getThrottlingLimits(){ >> QDBusMessage ret = >> QDBusCon->call(QDBusMessage::createMethodCall(DESTINATION,"/config","","get_ >> throttling_limits")); if(ret.type() == QDBusMessage::ErrorMessage){ >> qDebug() << "DBus Error:\n" << QDBusCon->lastError().name() << >> "\n" << QDBusCon->lastError().message(); >> return (false); >> } >> //ret.arguments().t >> return true; >> } >> >> How can I convert what the QDBusMessage arguments I got in ret to a QMap? > > The first variant in the arguments contains something that can be converted to > your map. Use: > > qdbus_cast<QMap<Key, Value> >(ret.arguments().first()); > >> I also don't understand for what the "Interface" parameter in >> createMethodCall is. It seems to work well with out this till now (I >> have only implemented DBus methodes till now, no signals). > > The D-Bus specification says that you can make calls to the empty interface > and > this needs to work, calling any method with that name in any interface. If you > have a specific interface in mind, use it. > > -- > Thiago Macieira - thiago.macieira (AT) intel.com > Software Architect - Intel Open Source Technology Center > Intel Sweden AB - Registration Number: 556189-6027 > Knarrarnäsgatan 15, 164 40 Kista, Stockholm, Sweden > > _______________________________________________ > Interest mailing list > Interest@qt-project.org > http://lists.qt-project.org/mailman/listinfo/interest >
Thanks for the fast answer. It still doesn't work.. I know that the value will be an int, but qdbus_cast<QMap<QString, int > >(ret.arguments().first()); returns a compiler error. So I used a QVariant map, which works for the compiler but the result is useless. My Code: QMap<QString, int> test; QVariantMap test2; //qdbus_cast<QMap<QString, int > >(ret.arguments().first()); //qDebug() << qdbus_cast<QMap<QString, QVariant > >(ret.arguments().first()); test2 = qdbus_cast<QVariantMap>(ret.arguments().first()); qDebug() << test2; qDebug() << test2.value("download"); The output: type end_dict_entry not a basic type type end_dict_entry not a basic type QMap(("download", QVariant(void*, ) ) ( "upload" , QVariant(void*, ) ) ) QVariant(void*, ) Thanks for your help. _______________________________________________ Interest mailing list Interest@qt-project.org http://lists.qt-project.org/mailman/listinfo/interest