Reputation: 1
void* filePtr = nullptr;
const auto couldInvoke = method.invoke(
path.get(),
Qt::DirectConnection,
QReturnArgument(method.returnMetaType().name(), filePtr),
Q_ARG(QString, fileName)
);
I used to create an dynamic QReturnArgument
as shown above. Invoking works, it is against the documentation, but I don't use the macros, and it is working.
in Qt 6.5 they introduced:
struct QMetaMethodReturnArgument
{
const QtPrivate::QMetaTypeInterface *metaType;
const char *name;
void *data;
};
I have no clue how to create this QMetaTypeInterface
dynamically for every type based on QMetaType
:
class QMetaTypeInterface
{
public:
ushort revision; // 0 in Qt 6.0. Can increase if new field are added
ushort alignment;
uint size;
uint flags;
QMTI_MUTABLE QBasicAtomicInt typeId;
I can not use that:
template <typename T> void qReturnArg(const T &&) = delete;
template <typename T> inline QMetaMethodReturnArgument qReturnArg(T &data)
{
return QtPrivate::Invoke::returnArgument(nullptr, data);
}
namespace QtPrivate {
class QMetaTypeInterface;
template<typename T> constexpr const QMetaTypeInterface *qMetaTypeInterfaceForType();
}
Is there an easier solution?
declaring it manually works, but it's too much effort.
I'm expecting to get a QMetaMethodReturnArgument
just by the QMetaType
, name and data.
Upvotes: 0
Views: 171
Reputation: 1
It's possible to use the following:
QMetaMethodReturnArgument(method.returnMetaType().iface(), nullptr, std::addressof(entity));
qt 6.7:
QTemplatedMetaMethodReturnArgument<void>{method.returnMetaType().iface(), nullptr, std::addressof(filePtr)},
Upvotes: 0