QVariant::value<T>() fails to convert unless QVariant::fromValue<T>() has been called previously.
This commit is contained in:
parent
885a618820
commit
19c5b80b24
|
@ -26,6 +26,7 @@
|
|||
**
|
||||
*************************************************************************/
|
||||
#include "vpsettings.h"
|
||||
#include "../vmisc/compatibility.h"
|
||||
|
||||
#include <QMarginsF>
|
||||
|
||||
|
@ -66,14 +67,14 @@ VPSettings::VPSettings(Format format, Scope scope, const QString &organization,
|
|||
QObject *parent)
|
||||
: VCommonSettings(format, scope, organization, application, parent)
|
||||
{
|
||||
qRegisterMetaTypeStreamOperators<QMarginsF>("QMarginsF");
|
||||
REGISTER_META_TYPE_STREAM_OPERATORS(QMarginsF)
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
VPSettings::VPSettings(const QString &fileName, QSettings::Format format, QObject *parent)
|
||||
: VCommonSettings(fileName, format, parent)
|
||||
{
|
||||
qRegisterMetaTypeStreamOperators<QMarginsF>("QMarginsF");
|
||||
REGISTER_META_TYPE_STREAM_OPERATORS(QMarginsF)
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
|
|
@ -69,9 +69,9 @@ auto main(int argc, char *argv[]) -> int
|
|||
#endif
|
||||
|
||||
// Need to internally move a node inside a piece main path
|
||||
qRegisterMetaTypeStreamOperators<VPieceNode>("VPieceNode");
|
||||
REGISTER_META_TYPE_STREAM_OPERATORS(VPieceNode);
|
||||
// Need to internally move a node inside a custom seam allowance path
|
||||
qRegisterMetaTypeStreamOperators<CustomSARecord>("CustomSARecord");
|
||||
REGISTER_META_TYPE_STREAM_OPERATORS(CustomSARecord);
|
||||
|
||||
#ifndef Q_OS_MAC // supports natively
|
||||
InitHighDpiScaling(argc, argv);
|
||||
|
|
|
@ -34,6 +34,24 @@
|
|||
#include <QVector>
|
||||
#include <QFontMetrics>
|
||||
|
||||
#include "defglobal.h"
|
||||
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
// WARNING:QVariant::load: unknown user type with name QMarginsF.
|
||||
// QVariant::value<T>() fails to convert unless QVariant::fromValue<T>() has been called previously.
|
||||
// https://stackoverflow.com/questions/70974383/qvariantvaluet-fails-to-convert-unless-qvariantfromvaluet-has-been-c
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 1, 0)
|
||||
#define REGISTER_META_TYPE_STREAM_OPERATORS(TYPE) \
|
||||
QMetaType::fromType<TYPE>().hasRegisteredDataStreamOperators(); // Dummy call
|
||||
#else
|
||||
#define REGISTER_META_TYPE_STREAM_OPERATORS(TYPE) \
|
||||
QVariant::fromValue<TYPE>(TYPE{}); // Dummy call
|
||||
#endif // QT_VERSION >= QT_VERSION_CHECK(6, 1, 0)
|
||||
#else
|
||||
#define REGISTER_META_TYPE_STREAM_OPERATORS(TYPE) \
|
||||
qRegisterMetaTypeStreamOperators<TYPE>(#TYPE);
|
||||
#endif // QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
|
||||
#if QT_VERSION < QT_VERSION_CHECK(5, 5, 0)
|
||||
#include "diagnostic.h"
|
||||
#endif // QT_VERSION < QT_VERSION_CHECK(5, 5, 0)
|
||||
|
|
|
@ -32,6 +32,7 @@
|
|||
#include "vabstractvalapplication.h"
|
||||
#include "projectversion.h"
|
||||
#include "../vmisc/vcommonsettings.h"
|
||||
#include "../vmisc/compatibility.h"
|
||||
|
||||
class VTestSettings : public VCommonSettings
|
||||
{
|
||||
|
@ -41,7 +42,7 @@ public:
|
|||
QObject *parent = nullptr)
|
||||
: VCommonSettings(format, scope, organization, application, parent)
|
||||
{
|
||||
qRegisterMetaTypeStreamOperators<QMarginsF>("QMarginsF");
|
||||
REGISTER_META_TYPE_STREAM_OPERATORS(QMarginsF);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -37,10 +37,11 @@
|
|||
#include <QPrinterInfo>
|
||||
#include <QtDebug>
|
||||
#include <QGlobalStatic>
|
||||
#include <QMargins>
|
||||
#include <QMetaType>
|
||||
|
||||
#include "../vmisc/def.h"
|
||||
#include "../vmisc/vmath.h"
|
||||
#include "../vlayout/vbank.h"
|
||||
#include "../vmisc/compatibility.h"
|
||||
#include "qglobal.h"
|
||||
|
||||
#ifndef QBS_BUILD
|
||||
|
@ -147,14 +148,14 @@ VValentinaSettings::VValentinaSettings(Format format, Scope scope, const QString
|
|||
QObject *parent)
|
||||
:VCommonSettings(format, scope, organization, application, parent)
|
||||
{
|
||||
qRegisterMetaTypeStreamOperators<QMarginsF>("QMarginsF");
|
||||
REGISTER_META_TYPE_STREAM_OPERATORS(QMarginsF);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
VValentinaSettings::VValentinaSettings(const QString &fileName, QSettings::Format format, QObject *parent)
|
||||
:VCommonSettings(fileName, format, parent)
|
||||
{
|
||||
qRegisterMetaTypeStreamOperators<QMarginsF>("QMarginsF");
|
||||
REGISTER_META_TYPE_STREAM_OPERATORS(QMarginsF);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
|
|
@ -34,10 +34,8 @@
|
|||
#include <QSettings>
|
||||
#include <QString>
|
||||
#include <QtGlobal>
|
||||
#include <QMargins>
|
||||
|
||||
#include "vcommonsettings.h"
|
||||
#include "../vlayout/vbank.h"
|
||||
|
||||
class VValentinaSettings : public VCommonSettings
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue
Block a user