mirror of
https://github.com/jankae/LibreVNA.git
synced 2026-04-10 00:43:41 +00:00
Save calibration kit as json
This commit is contained in:
parent
1dab72238b
commit
68f660ff1c
7 changed files with 25956 additions and 270 deletions
29
Software/PC_Application/Util/qpointervariant.h
Normal file
29
Software/PC_Application/Util/qpointervariant.h
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
#ifndef QPOINTERVARIANT_H
|
||||
#define QPOINTERVARIANT_H
|
||||
|
||||
#include <QVariant>
|
||||
|
||||
class QPointerVariant {
|
||||
public:
|
||||
template <typename T> QPointerVariant(T *ptr)
|
||||
: ptr(static_cast<void*>(ptr)),
|
||||
variant(QVariant(*ptr)){};
|
||||
void setValue(const QVariant &value) {
|
||||
auto destType = variant.type();
|
||||
if(!value.canConvert(destType)) {
|
||||
throw std::runtime_error("Unable to convert QVariant to requested type");
|
||||
}
|
||||
variant = value;
|
||||
variant.convert(destType);
|
||||
QMetaType mt(destType);
|
||||
mt.construct(ptr, variant.constData());
|
||||
}
|
||||
QVariant value() {
|
||||
return QVariant(variant.type(), ptr);
|
||||
}
|
||||
private:
|
||||
void *ptr;
|
||||
QVariant variant;
|
||||
};
|
||||
|
||||
#endif // QPOINTERVARIANT_H
|
||||
Loading…
Add table
Add a link
Reference in a new issue