P
P
Pavel K2015-05-30 20:17:24
Qt
Pavel K, 2015-05-30 20:17:24

How to make a proxy class for a class or something like that?

Greetings!
I am writing a plugin for a Qt program, there
was an urgent need to make a proxy class to a class about which nothing is known, except for its ancestor (there is an ancestor implementation and header)
, I can get a pointer to this class when it is created before any changes, etc.
Ideally, I would like my proxy to be em like a "transparent proxy",
i.e. just skip all calls to functions that do not exist in the proxy class and the original one.
Or at least replace the ancestor of the original class with your own (having inherited from it at the same time), but so that all the values ​​​​of its variables would be transferred.
I need this so that I can then, in the right places, um ... cast the original one to my proxy class and set my own values.
UPDT: Yes, it would be easier to store pointers to the source in the list and use them to look at the correspondence of which source class will correspond to mine, but the lifetime of the plugin is limited and it does not live throughout the program.
I apologize for the confusion and probably indistinctness ... I myself don’t seem to understand how it can be at all ...

Answer the question

In order to leave comments, you need to log in

1 answer(s)
P
Pavel K, 2015-05-30
@PavelK

Damn, something I'm dumb.
Everything is simpler, the base class (everything is known about it) of the original class is the heir of QObject, so there is a setParent () method.
Therefore, when I get a pointer to the source class, I create my own class, for which I set the source class as a parent (so as not to bother with deletion later), I cast the source class to QObjcet and setParent (my class).

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question