Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
PaintEvent and class topology...
More and more this seems like a philosophical QT question. I have a widget representing a window A I have a widget representing a window, deriving from A, called B
B draws its stuff, but I want "A" to contribute some drawing, e.g. draw an image OVER what "B" draws. I want "B" to be completely unaware of this, not having to cooperate with "A" other than deriving from it.
Is that possible?
goetz last edited by
It is possible, but only with some tricks - it's more a C++ problem than Qt, though.
C++ has the concept of virtual methods, if you reimplement paint() in your subclass B, this method is called, never the method of A. So B has to explicitly call A->paint().
You can declare a virtual method paintPrivate() in class A. Then reimplement paint() in A and call paintPrivate() there. This will call B's paintPrivate(), you then can do your additional stuff in A's paint(). BUT this will only work as long as you do not reimplement paint() in B. If you do everything is lost again.
are paint(), privatePaint() part of QT framework? I am not fully familiar with the entire framework. I'm coming from the "beautiful" world of GDI, Win32 and .NET.... :-)
forget the privatePaint question, i am at the end of a very tiresome week.