P
P
Pavel K2016-12-19 21:51:46
Qt
Pavel K, 2016-12-19 21:51:46

Is it possible to use define to change the implementation of a function, or what is the best way to do this?

Greetings!
There is an implementation of such a function, which is generated by Qt's MOC generator:

int ClassA::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QObject::qt_metacall(_c, _id, _a);
    ....
}

I need to change its implementation, but since Qt does not have this moment thought out, then you have to come up with crutches.
The function should look like this:
int ClassA::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = InterfaceA::qt_metacall(_c, _id, _a);
    ....
}

Is there any way to change the implementation?
PS You need to replace only within this function, and not everywhere.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
P
Pavel K, 2016-12-22
@PavelK

Damn, I didn’t answer for the bazaar - the Qt Meta system is thought out very cool!
True, 3 days passed before I figured it out, but now you don’t need to redefine anything, just like fiddling with define.
It was worth digging deeper into qmetatype.h along with the debugger and understanding each step, everything fell into place.

A
Alexander Rulev, 2016-12-20
@Rulexec

I do not program in C ++, I do not use Qt, but it seems that your moc is a separate tool that participates in the build process. There is no problem after it to run a program in any language that will perform a slightly smarter preprocessing, finding a position in the file ClassA::qt_metacalland then replacing the first occurrence QObject::qt_metacallwith InterfaceA::qt_metacall.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question