mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-10 14:07:35 +08:00
refs #314, fromQVariant / location of toQVariant
* renamed fromQVariant to convertFromQVariant, the "from" methods imply the object is changed (fromJson, fromString ..) * implemented fromQVariant - changing the object by QVariant * moved toQVariant into PQ template * free function setFromQVariant
This commit is contained in:
@@ -107,6 +107,18 @@ namespace BlackMisc
|
||||
*/
|
||||
QString qVariantToString(const QVariant &qv, bool i18n = false);
|
||||
|
||||
/*!
|
||||
* Checked version from QVariant
|
||||
*/
|
||||
template <class T> void setFromQVariant(T *value, const QVariant &variant)
|
||||
{
|
||||
Q_ASSERT(variant.canConvert<T>());
|
||||
if (variant.canConvert<T>())
|
||||
{
|
||||
(*value) = variant.value<T>();
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
* Fix variant. Required if a variant "comes in" via DBus,
|
||||
* and represents a QDBusArgument rather than the real type.
|
||||
|
||||
Reference in New Issue
Block a user