[Qt-interest] Basic update() paint - more info
Tony Rietwyk
tony.rietwyk at rightsoft.com.au
Fri Jan 30 07:28:25 CET 2009
Phil wrote:
> On Friday 30 January 2009 10:36:11 andrew.m.goth at l-3com.com wrote:
>
> Thanks again for your time Andy.
>
> I've had a couple of days to think about this and to
> experiment further and
> now I defiantly know where the problem lies but I cannot find
> a solution. I'm
> back where I started; I seem to have made an error after I
> promoted the frame
> widget to my map class.
>
> This is from my base class constructor:
>
> Base::Base ( QWidget* parent, Qt::WFlags fl )
> : QMainWindow ( parent, fl ), Ui::MainWindow()
> {
> setupUi ( this );
>
> map = new Map(mapFrame);
> }
>
> The following statement calls the map class functonX() where
> I simply have an
> update() statement;
>
> map->functionX();
>
> This triggers the paint event as I described previously; the
> two rectangles
> are not alternatively painted in magenta and yellow. If I
> omit the map = new
> Map(mapFrame) statement and include a timer signal / update
> slot instead in my
> map class then the rectangles are displayed correctly. Also,
> the window,
> including the frame, is repainted correctly if it's resized
> or uncovered but
> only if I omit the Map(mapFrame) statement. This must mean
> the the error has
> to do with the promotion of the frame or something omited
> from the map
> constructor itself, perhaps.
>
> This is the map class constructor:
>
> Map::Map(QWidget *parent)
> : QFrame(parent)
>
> Does any of this make any sense at all and show where I've
> made an error?
>
> --
> Regards,
> Phil.
Hi Phil,
Have a look at the generated _ui.h file - you should see that the map object
is being created in the setupUi routine.
It seems you are then creating a second map object in the main window
constructor, with the first one as parent! If the second one is in front-of
of the first, then any changes to the first may not be visible - or vice
versa.
Hope that helps,
Tony Rietwyk
More information about the Qt-interest-old
mailing list