QT: Have parent Widget class draw something in addition to the child class widget
-
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?
-
Answer:
Override http://doc.trolltech.com/latest/qwidget.html#event in A: bool A::event ( QEvent * e) { bool handled = QWidget::event(e); if(e->type() == QEvent::Paint) { // cast e to QPaintEvent and do the overlay painting } return handled; }
RM1970 at Stack Overflow Visit the source
Other answers
I'm no QT expert, but you could do this in a hacky way by having A delegate its drawing to a child component of identical size located at (0,0). Naturally, the child component would be drawn after your window widget in the hierarchy, and so this would achieve what you're after.
Nathan Pitman
Related Q & A:
- How to display child page from specific parent page in homepage?Best solution by WordPress
- How to target the parent div from child div?Best solution by Stack Overflow
- How to build child modules independently from parent in Maven?Best solution by stackoverflow.com
- How do you ship something first class international?Best solution by ehow.com
- Who is Youth Allowance for the parent or the child?Best solution by Yahoo! Answers
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
For every problem there is a solution! Proved by Solucija.
-
Got an issue and looking for advice?
-
Ask Solucija to search every corner of the Web for help.
-
Get workable solutions and helpful tips in a moment.
Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.