[Interest] Issue painting over child widgets

Jason H scorp1us at yahoo.com
Thu Nov 17 22:40:55 CET 2011


raise()?



________________________________
From: "Murphy, Sean M." <sean.murphy at gd-ais.com>
To: "interest at qt-project.org" <interest at qt-project.org>
Sent: Thursday, November 17, 2011 4:28 PM
Subject: Re: [Interest] Issue painting over child widgets

>Create the overlay widget as an independent child of the top level 
>widget (not the widgets layout).

My original layout was done in Designer, but I assume I can't do this step in Designer, I must do it in my MainWindow's constructor?

>Raise it to the top of the stack.

This step seems to be my sticking point.  How do I manipulate the order of the QObject/QWidget stack?  The only semi-relevant function I see is QObject::children(), but that returns a const QObjectList&, so I don't see how I can manipulate it...

>Manually move() and resize() it to fit the parent.
>Overload the parents ::resize event handler and re-adjust it there as 
>well.
>In the Overlay::paintEvent Draw a big X from corner to corner of the
>rect() to prove that it is being resized properly as you resize the 
>parent.

These parts I get!
Sean

>
>> I'm a little blind to how I go about putting a widget above another
>widget.  Assuming I can get step #1 figured out, steps 2-4 look pretty 
>simple...
>>
>> Sean
>>
>>> 1 - Place a widget over the label widgets in question.
>>>
>>> 2 - setAttribute(Qt::WA_TransparentForMouseEvents,true);
>>>     so that it becomes transparent to mouse events.
>>>
>>> 3 - Use a transparent background so you can see the widgets beneath.
>>>
>>> 4 - Draw (animation) on it whatever you want to appear floating
>>>     above the widgets beneath and violating the otherwise rigid
>>>     rectangular widget boundaries.
>>>
>>> Bill
>>>
>>>
>>>> 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
>>>> Interest at qt-project.org <mailto:Interest at qt-project.org> 
>>>> http://lists.qt-project.org/mailman/listinfo/interest
>>>>
>>>
>>> _______________________________________________
>>> Interest mailing list
>>> Interest at qt-project.org
>>> http://lists.qt-project.org/mailman/listinfo/interest
>> _______________________________________________
>> Interest mailing list
>> Interest at qt-project.org
>> http://lists.qt-project.org/mailman/listinfo/interest
>>
>
>
>_______________________________________________
>Interest mailing list
>Interest at qt-project.org
>http://lists.qt-project.org/mailman/listinfo/interest

_______________________________________________
Interest mailing list
Interest at qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20111117/513fa082/attachment.html>


More information about the Interest mailing list