本文整理汇总了C++中QMap::put方法的典型用法代码示例。如果您正苦于以下问题:C++ QMap::put方法的具体用法?C++ QMap::put怎么用?C++ QMap::put使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QMap
的用法示例。
在下文中一共展示了QMap::put方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: interfaceError
QList<QVariantMap> TrackListInterfaceTest::testGetTracksMetadata(const QList<QDBusObjectPath>& trackIds)
{
QDBusReply<QList<QVariantMap> > reply = iface->call("GetTracksMetadata");
if (!reply.isValid()) {
emit interfaceError(Method, "GetTracksMetadata", "Call to GetTracksMetadata failed with error " + reply.error().message());
} else {
QList<QVariantMap> metadataList = reply.value();
QMap<QDBusObjectPath,QVariantMap> metadataMap;
int i = 0;
Q_FOREACH (const QVariantMap& metadata, metadataList) {
if (metadata.isEmpty()) {
emit interfaceWarning(Method, "GetTracksMetadata",
"Got an empty entry at position " + QString::number(i));
} else if (!metadata.contains("mpris:trackid")) {
emit interfaceError(Method, "GetTracksMetadata",
"No mpris:trackid entry at position " + QString::number(i));
} else if (metadata.value("mpris:trackid").userType() != qMetaTypeId<QDBusObjectPath>()) {
emit interfaceError(Method, "GetTracksMetadata",
"mpris:trackid entry was not sent as a D-Bus object path (D-Bus type 'o') at position " + QString::number(i));
} else {
QDBusObjectPath trackid = metadata.value("mpris:trackid").value<QDBusObjectPath>();
if (trackid.path().isEmpty()) {
emit interfaceError(Method, "GetTracksMetadata",
"mpris:trackid entry is an empty path at position " + QString::number(i));
} else if (!trackIds.contains(trackid)) {
emit interfaceWarning(Method, "GetTracksMetadata",
"Entry " + trackid.path() + " was not requested at position " + QString::number(i));
} else {
metadataMap.put(trackid, metadata);
}
}
++i;
}
}
}