QMetaObject is a class from the Qt Toolkit which provides meta-information about Qt objects.
Questions tagged [qmetaobject]
61 questions
1
vote
0 answers
QMetaObject::invokeMethod returns true but doesn't execute the solt
I'm trying to run a public slot in another thread using invokeMethod:
QMetaObject::invokeMethod(m_manager, "onEventRequest", Qt::QueuedConnection, Q_ARG(int, 0));
Now, invokeMethod returns true and no error message are reported, but the slot…

Zhao Leo
- 101
- 1
- 3
1
vote
1 answer
QMetaObject invoke on overloaded operators
Has anyone tried to invoke overloaded operator << on a QObject.
For example i have a class
class Worker : public QObject
{
Q_OBJECT
public:
explicit Worker(QObject *parent = 0);
Q_INVOKABLE virtual void operator<<(char p);
};
When i…

GeneralFailure
- 1,085
- 3
- 16
- 32
1
vote
1 answer
Qt metaObject->indexOfMethod always return -1
I have one function declared in Foo class:
Q_INVOKABLE void setImageUrl(const QString &imageUrl);
However I cannot get the function index of that method:
Foo* foo = new Foo();
const QMetaObject* metaObject = foo->metaObject();
QString…

Niklas
- 23,674
- 33
- 131
- 170
1
vote
1 answer
Q_PROPERTY WRITE get index
I have this property:
Q_PROPERTY(int _a READ a WRITE setA NOTIFY aChanged)
I know only the property's name _a. I would like get the index of the method setA.

artoon
- 729
- 2
- 14
- 41
1
vote
1 answer
Enumerate QML properties in Qt C++?
Im doing the following to render a QML in my Qt embedded app:
QDeclarativeView *view = new QDeclarativeView(this);
view->setSource(QUrl::fromLocalFile("dial.qml"));
view->show();
QObject *dial = view->rootObject();
Is there a way i can enumerate…

thecoder
- 55
- 8
1
vote
1 answer
Class name from QMetaProperty
I am working on making my own designer widget that looks and functions like qt. But now I needed to know how the property is created. I knew we can get the properties of an widget using QMetaObject and QMetaProperty but my question is will I be able…

anbu selvan
- 725
- 3
- 13
- 41
0
votes
1 answer
Check if method is invokable in Qt
My Qt5/C++ program creates a method name (string) on the fly and then if the method is invokable will call it (using invokemethod). And if not invokable/does not exist, then it will no attempt to invoke it. My methods would be defined like…

TSG
- 4,242
- 9
- 61
- 121
0
votes
1 answer
I am getting an error on Qt, and can't figure out where I went wrong
So, I am learning my way around Q_PROPERTY, QMetaObject and QMetaProperty.
I have built a working GUI, but whenever I run the script, I get an error
Can anyone tell me what I did wrong/am doing wrong?
The QDout() function, as mentioned, is only…

Martin Sieburg
- 87
- 5
0
votes
0 answers
How can I test method calling QMetaObject::invokeMethod with Qt::QueuedConnection -- using gtest gmock framework
Suppose I have a method and I want to test it using gtest/gmock framework. This method calls another method inside itself using a Qt queued invoke:
void MyClass::handleFoo()
{
// ...
Q_ASSERT(QMetaObject::invokeMethod(this, "handleBar",…

JenyaKh
- 2,040
- 17
- 25
0
votes
0 answers
readOnGadget for a Q_GAGDET inside a Q_GADGET not working as expected
I have a "top level" Q_GADGET and, inside this Q_GADGET, I have a pointer to another Q_GADGET. I am trying to use the function readOnGadget to display the values stored by both objects. I can do this just fine with the top level Q_GADGET, however…

Raphael Sauer
- 630
- 1
- 6
- 27
0
votes
1 answer
Proper way to add enum class to metaObject Qt 5.15
I'm tinkering a bit with Qt's meta-object system, and I've come across an issue with adding enum class to a meta-object. I have a struct that contain some variables, one of which is an enum class.
#ifndef EXAMPLE_H
#define EXAMPLE_H
#include…

Raphael Sauer
- 630
- 1
- 6
- 27
0
votes
0 answers
Wy is QMetaObject::invokemethod searching for a function from the wrong object
In my work project I have run into a particularly strange behaviour. During runtime, when calling QMetaObject::invokeMethod, I get a print indicating that the program is trying to find the specified method from QObject, instead of the actual class…

Narmondur
- 111
- 1
- 2
- 7
0
votes
0 answers
QMetaType confuses two symbols with identical name but different namespace
Consider the following minimal example:
namespace foo { struct MyStruct {}; }
Q_DECLARE_METATYPE(foo::MyStruct)
namespace bar { struct MyStruct {}; }
Q_DECLARE_METATYPE(bar::MyStruct)
// later on near the entry point of the…

Petr Mánek
- 1,046
- 1
- 9
- 24
0
votes
0 answers
Register inherited QObject's meta object to QJSEngine
I would like to inherit the QObject class, and register the inherited class's meta object to a QJSEngine instance, so that I can call let instance = new TrialObject(); in JavaScript. Here is my code:
from PyQt6.QtQml import QJSEngine
from…

SamG101
- 488
- 1
- 7
- 18
0
votes
1 answer
QMetaObject::invokeMethod does not call slot
I have a public signal called UpdateScreenshots in the workspacemanager class that takes screenshots of some widgets. It then returns these screenshots in a struct I've defined. This call is made from a thread as taking screenshots can apparently…

Mr.Grease
- 197
- 1
- 13