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
0
votes
2 answers

Enum property not being recognized as such

I have been trying to implement something that I believe should be pretty straightforward, but am having issues with it. In short, I have a class that has some Q_Properties, some of which I want to be namespace-level enum values. My issue is, if I…
Cobalt
  • 938
  • 9
  • 21
0
votes
2 answers

Functionpointer based syntax for QMetaObject invokeMethod

I'm working on a simple wrapper for a IPC lib we are using. I want to convert the events from this lib to calls on Qt slots. Right now i have something like this: void Caller::registerCallback(int id, QObject* reciever, const char* member) { …
dashro
  • 48
  • 4
0
votes
0 answers

Qt invoke method directly to the QThread eventloop

In my application I'm using a non-Qt class that spawns its own thread. This object listens on a device and calls a callback each time the device received a packet. In my Device class (derrived from QObject), I have a static function, that receives…
bemerged
  • 31
  • 5
0
votes
1 answer

How to check if it's a valid QObject pointer, created by QMetaType::create()

I need to convert QVariant to other user custom classes. All classes have to be derived from QObject. I can check at compilation time the destination type because it's a template but the source is a QVariant so, it cannot be checked. My…
marco
  • 1,686
  • 1
  • 25
  • 33
0
votes
2 answers

Passing std::unique_ptr as qt signal argument with std::move

I'm working in Qt, I didn't mention it, because I thought it was just C++ problem. I solved this problem with shared pointers, so don't give me solution. But it's question of comprehending, I want to understand why it's not working. I was trying the…
Herman
  • 155
  • 4
  • 13
0
votes
1 answer

Set property value of QObject by index, not name

In my publisher-subscriber class the Qt components subscribe by their property names. The publisher maps the pairs to the names of the publishable variables. { VarName -> [(QObject*, PropName)] } On variable…
Valentin H
  • 7,240
  • 12
  • 61
  • 111
0
votes
1 answer

cannot connect QMetaMethod with lambda

I have a base class Binded settings to bind property in it with given widgets, like LineEdit in example. I stuck with connecting signals and slot. As i see it's the same as provided code in answer on How to use QMetaMethod with QObject::connect …
Greadimar
  • 81
  • 8
0
votes
0 answers

Documentation on QMetaObject::connect

I searched the web and docs for documentation on QMetaObject::connect. It looks intriguing because it connects signals and slots by their indices. I see it used in a couple places including an implementation of dynamic signals and slots. I also…
user3761340
  • 603
  • 5
  • 19
0
votes
1 answer

Obtain property changed notifier from meta-object

I want to write a property connector for connecting properties in C++ Qt in QML manner. It could be like this: new PropConnector ( receiver, "propName", sender, "propName" ); The propConnector class is a small QObject class which uses sender as…
Valentin H
  • 7,240
  • 12
  • 61
  • 111
0
votes
1 answer

Using qRegisterMetaType on object pointer with Qt5 throws unresolved errors

I'm currently porting my application from Qt4.8 to Qt5.6 Some code that use to compile and link now stopped linking properly. I narrowed it down to a call to qRegisterMetaType where MyClass* inherits from QObject. MyClass is defined and…
Julien M
  • 657
  • 3
  • 10
  • 40
0
votes
1 answer

QMetaObject::newInstance failes if type is in namespace

I want to create a new instance of class A that inherits a base class derived from QObject. In case A isn't in a namespace this works fine, but in case A is in a namespace this call returns a null pointer: QObject *o =…
darkfirewave
  • 82
  • 1
  • 7
0
votes
1 answer

Disambiguation with QMetaObject::invokeMethod and multiple candidates

I wonder if it is possible to call a method with QMetaObject::invokeMethod, if the method has optional parameters like this. class Foo { Q_INVOKABLE void myMethod(int a, bool b = true); } I have tried : QMetaObject::invokeMethod(foo,…
Olivier CLERO
  • 177
  • 15
0
votes
0 answers

How to pass a pointer to QMetaObject::newInstance() using Q_ARG

I am trying to call an object's constructor using the QMetaObject::newInstance method. Below I have two examples of constructors I am going to use, one with pointers and one with only basic types: class A : public QObject { Q_OBJECT public: …
jbrand1
  • 61
  • 5
0
votes
1 answer

New QObject::connect syntax doesn't work

I'm using the new syntax for QObject::connect to connect a signal to a slot: connect(m_pNetworkReply, &QNetworkReply::error, this, &MyClass::onError); but I'm getting this weird error and I have no idea…
Jacob Krieg
  • 2,834
  • 15
  • 68
  • 140
0
votes
0 answers

Read Access Violation while trying to serialize a QObject class using QSettings

Hi everyone i have a foo class which is inherited from QObject and i want to serialize using QSettings. Code in foo.h namespace GUI { class Foo : public QObject { Q_OBJECT Q_PROPERTY(QString mem1 READ mem1 WRITE setMem1 NOTIFY…
bourne
  • 1,083
  • 4
  • 14
  • 27