Parents paint first, then children.
However what you can do is create the layout of widgets you need, then render()
that parent widget to a pixmap, which you then combine in your own overlay
class with what ever you need to overlay. You then take the mouse events and
send them as needed to the controls.
However with QGraphicsView you can do all that, even more easily.
________________________________
From: "Murphy, Sean M." <[email protected]>
To: "[email protected]" <[email protected]>
Sent: Thursday, November 17, 2011 10:50 AM
Subject: [Interest] Issue painting over child widgets
I'm trying to create an animation effect for a Photo Booth application, and I'm
having trouble getting the animation to paint over child widgets. Here's the
setup:
I've got a QMainWindow with 5 QLabels on it and a QPushButton. Call the
QLabels "camera" and "image1" - "image4". So the idea is that the "camera"
label is always showing a live feed from the digital camera. When the user
presses the pushbutton, a timer starts that snaps four images over a period of
time and puts those images in labels "image1" - "image4", respectively. This
all works fine, but I wanted to make it look a little more polished by adding
an animation.
So what I'd like to happen is when the timer fires off to grab an image, I want
that image to appear to move from the "camera" label to the correct "image"
label. So it should appear to jump off from the "camera" label, float over the
top of everything, and land on the desired "image" label.
So my first attempt was to override the paintEvent() of my QMainWindow, create
a QPainter and use drawPixmap() to draw my floating image. It's drawing my
image, but the image is showing up under all the child widgets, instead of over
the top of everything.
Here's my paintEvent() code:
void MainWindow::paintEvent(QPaintEvent *e)
{
QMainWindow::paintEvent(e);
if (showMovingPixmap == true)
{
QPainter painter(this);
painter.setClipping(false);
painter.drawPixmap(movingPixmapXPos,movingPixmapYPos,movingPixmap);
movingPixmapXPos++;
movingPixmapYPos++;
}
}
So what am I missing? Would it be easier to change my application to have a
QGraphicsView as the child widget of the QMainWindow, and do everything on a
QGraphicsScene?
Sean
_______________________________________________
Interest mailing list
[email protected]
http://lists.qt-project.org/mailman/listinfo/interest_______________________________________________
Interest mailing list
[email protected]
http://lists.qt-project.org/mailman/listinfo/interest