Questions tagged [qmetaobject]

QMetaObject is a class from the Qt Toolkit which provides meta-information about Qt objects.

Documentation can be found here (Qt4) and here (Qt5).

61 questions
35
votes
1 answer

Is it possible to disconnect all of a QObject's connections without deleting it

I have a QObject A, this is connected to another QObject B. Now I want A to connect to C, a third QObject and to completely disconnect from B. Easy peasy! Trouble is I have a lot of of A's each with their own set of signals and slots (B's/C's are…
Troyseph
  • 4,960
  • 3
  • 38
  • 61
10
votes
1 answer

fail to use Q_OBJECT Macro in CMake Project

I am having trouble with the meta Object Compiler of Qt in my CMake Project. A shared lib I am building contains the following code and employs the pimpl idiom. After invoking CMake and upon compilation I get AUTOGEN: error:…
CD86
  • 979
  • 10
  • 27
9
votes
1 answer

How to find out from the slot which signal has called this slot?

I mean if I have many different signals which are connected to the same slot. I saw this question but can't understand the link in the answer. Can you give me simple example?
ratojakuf
  • 708
  • 1
  • 11
  • 21
8
votes
5 answers

How can I find a Qt metaobject instance from a class name?

Is there a way to find the QMetaObject instance of a class, given the class name? what I like to do is to load objects from disk, but for this to happen, I need a way to retrieve a QMetaObject instance using the name of a class, in order to use the…
axilmar
  • 836
  • 1
  • 13
  • 17
7
votes
3 answers

Is there a way to use QMetaEnum with Q_ENUMS belonging to non Q_OBJECT or Q_GADGET class?

For example I have the following class: namespace someName { class someClass { Q_ENUMS(ESomeEnum) public: enum ESomeEnum {ENUM_A, ENUM_B, ENUM_C}; // ... some other things .. …
misilita
  • 73
  • 1
  • 3
4
votes
3 answers

Is there a way to find QObject child by class name?

It is possible to find a child if we know its type and name (if specified) like this: QPushButton *button = parentWidget->findChild("button1"); However each QObject has metaObject() function property which returns QMetaObject*. In…
Aleksey Kontsevich
  • 4,671
  • 4
  • 46
  • 101
3
votes
1 answer

How can I follow OOP base concepts with QObject derived class instance?

Hi, all... I'm working with Qt not for a long time, but recently a thought came to my mind. QObject has public function children() and a few other ones, which return pointer to a child object(s). So any client of custom class can break…
Illia Levandovskyi
  • 1,228
  • 1
  • 11
  • 20
2
votes
1 answer

Why is it not possible to use Q_OBJECT with template classes?

There's a similar question here that was looking for a workaround and a nice guide here which describes the meta-object system in Qt.But that doesn't explain directly why is it not possible to use a template class in the meta-object system.That's an…
Parsa Mousavi
  • 1,052
  • 1
  • 13
  • 31
2
votes
1 answer

cannot resolve Qt's QMetaObject::invokeMethod: No such method error

I am trying to develop a generic function which determines whether two QObjects are equal. In order for this to be possible, the functions being compared must have an 'equals' method that compares various function values in each and returns true if…
2
votes
1 answer

QMetaMethod::invoke() with argument defaults

When calling QMetaMethod::invoke() on a method that contains default arguments, the invoke fails. class MyClass : public QObject { Q_OBJECT public: Q_INVOKABLE MyClass() : QObject(nullptr){} public slots: int MyMethod(int a = 0) { …
mrg95
  • 2,371
  • 11
  • 46
  • 89
2
votes
3 answers

lua_newuserdata placement new on QMetaObject

I'm trying to integrate Lua with Qt's QMetaObject system. I have a class that derives from QObject that I bind to Lua based on the class name using QObject::staticMetaObject. main.h: #ifndef MAIN_H #define MAIN_H class Test : public QObject { …
mrg95
  • 2,371
  • 11
  • 46
  • 89
2
votes
1 answer

Q_ENUM to ostream

In a project is custom logger which I would like to extend to write enum values as qDebug() does. It there some easy way doing so? Here is something I thought may work(and it doesn't): template typename…
Libor Tomsik
  • 668
  • 7
  • 24
2
votes
1 answer

Serialize nested user defined class from Q_PROPERTY in QT

faced with following problem: I can't serialize user defined object from Q_PROPERTY I try to serialize RegistersSettings class to QDataStream. The idea is to be able to serialize it to text file (using << operator) and later be able to read it…
EagleNN
  • 63
  • 1
  • 5
2
votes
1 answer

Is Qt's meta system really that tedious?

I would like to use Qt's reflection mechanism since C++ lacks of this feature. It seems to work, but calling all the macros and helper functions is very tedious. For example to register an enum as a proper meta type I had to go through all the…
Nils
  • 13,319
  • 19
  • 86
  • 108
2
votes
1 answer

Translating a Q_ENUM keys

I use the Q_ENUM macro in my code, and then I use the associated QMetaEnum to populate a QComboBox. Is there any "standard" way to manage the translation of the Q_ENUM keys (retrieved with QMetaEnum::key() method)? I didn't find anything in the Qt's…
Aurelien
  • 1,032
  • 2
  • 10
  • 24
1
2 3 4 5