QMetaObject is a class from the Qt Toolkit which provides meta-information about Qt objects.
Questions tagged [qmetaobject]
61 questions
2
votes
1 answer
Qt - Does a derived class inherit its base class's meta properties?
I am working with Qt and came across class hierarchies where a base class (sometimes an abstract class) contains Q_PROPERTY macros; will a derived class inherit each Q_PROPERTY from its base class?

ethane
- 2,329
- 3
- 22
- 33
2
votes
2 answers
How to go about serializing a large, complex object?
I have a "User" class with 40+ private variables including complex objects like private/public keys (QCA library), custom QObjects etc. The idea is that the class has a function called sign() which encrypts, signs, serializes itself and returns a…

Quoi
- 135
- 1
- 8
2
votes
3 answers
No slots but QMetaObject::connectSlotsByName error using Qt and C++
I'm programming in C++ and Qt Creator and my code works perfectly. Nevertheless I've got the problem that I get a warning when I compile my code.
QMetaObject::connectSlotsByName: No matching signal for on_but_PrintTab_clicked()
There used to be a…

user3443063
- 1,455
- 4
- 23
- 37
2
votes
2 answers
Qt metaobject system: emit signal using a string with its name
Qt signal/slot system rocks, but looks that it lacks some really useful functionality (or at least I can't find how to use it). I have a class with lots of signals, and this class has a switch which needs to emit a proper signal depending on a…

ScumCoder
- 690
- 1
- 8
- 20
2
votes
1 answer
Introspection with QMetaProperty
I have a class ObjectA
class ObjectA : public QObject
{
Q_OBJECT
Q_PROPERTY(int _a READ a WRITE setA NOTIFY aChanged)
public:
ObjectA(int a) : _a(a) {}
int a() const { return _a;}
public slots:
void setA(int a) { _a = a; emit…

artoon
- 729
- 2
- 14
- 41
2
votes
2 answers
No matching function to call - compiler says I call (QObject *&) when call is (QObject *)
This is the code:
void invokeQMLFunction2Arg(QObject * object, QString func, QVariant p1, QVariant p2) {
QMetaObject::invokeMethod(object, func, Qt::DirectConnection, Q_ARG(QVariant, p1), Q_ARG(QVariant, p2));
}
This is the error:
error: no…
user2341104
1
vote
2 answers
Get object instance class name with Qt's meta-object system
I have 3 classes:
class Being : public QObject {
Q_OBJECT
public:
explicit Being(QObject *parent = nullptr);
};
class Animal : public Being {
Q_OBJECT
public:
explicit Animal(QObject *parent = nullptr);
};
class Dog : public Animal…

Jacob Krieg
- 2,834
- 15
- 68
- 140
1
vote
0 answers
Qt - Compile-time check if qRegisterMetaType() was called
Question: Is there a way to check at compile-time if qRegisterMetaType() was called for a custom type T?
The custom type T needs to be registered in Qt meta-type system in order to be used in e.g. queued connections.
If such a connection is…

sthlm58
- 1,142
- 1
- 9
- 28
1
vote
1 answer
PySide2 crashes while accessing QObject::property()
So I am not sure this is a bug or something but I have spent quite sometime to figure this out but couldn't. The problem happens when accessing calling QObject::property() function.
Here is a minimal reproducible example:
import sys
from PySide2…

reckless
- 741
- 12
- 53
1
vote
2 answers
How to convert Q_ENUM to QString for QT > 5.11 most efficient way?
I read several advices how to get an actual QString from a Q_ENUM value.
Below are 3 possible ways, I came up with, that are compilable constructs in QT5.11.1
What of them should one prefer and why?
void…

darkmattercoder
- 325
- 6
- 26
1
vote
1 answer
Is it possible to have a macro function as a QMetaMethod tag?
Qt allows you to have arbitrary tags on slots/Q_INVOKABLE methods using this syntax:
// In the class MainWindow declaration
#ifndef Q_MOC_RUN
// define the tag text as empty, so the compiler doesn't see it
# define MY_CUSTOM_TAG
#endif
...
private…

empyrical
- 362
- 2
- 5
- 16
1
vote
2 answers
Qt invokeMethod calling function having output argument
I am trying to figure out the usage of QMetaObject::invokeMethod. I have a function that has one argument(non-const QString), I want it to be the output, the function has no return value, calling invokeMethod on it always fails, while another…

oldnavy
- 177
- 1
- 3
- 9
1
vote
0 answers
Adding options to existing Q_PROPERTY from base class only in dereived class
I have a very simple base class which defines a normal Q_PROPERTY with READ and NOTIFY (WRITE is not in all dereived implementations possible).
class BaseClass : public QObject {
Q_OBJECT
Q_PROPERTY(QStringList someEntries READ someEntries…

feedc0de
- 3,646
- 8
- 30
- 55
1
vote
1 answer
Qt4.8: Why enum not seen in qmetaobject? And how to get worked?
Define of "function" I can't refactor. But need use in test class.
Used Qt 4.8. The following code return 1, but expected 2.
How to use typedef enum in test class?
#include
#include
#include
typedef enum {
READ …

Andrey Reeshkov
- 331
- 5
- 14
1
vote
2 answers
Enum in Qt property
I have a code, which works with Qt 5.5 and doesn't with Qt 5.2. Problem is with this enum:
#include
enum Area
{
Area_A,
Area_B,
Area_C
};
Q_DECLARE_METATYPE(Area)
Then I have an object, which exposes this area…

yudjin
- 349
- 5
- 14