[Qt-interest] Basic update() paint - more info

andrew.m.goth at l-3com.com andrew.m.goth at l-3com.com
Tue Jan 27 03:18:06 CET 2009


Phil wrote:
> This is how I'm currently calling the Map class function from 
> the base class:
>   Map map(mapFrame);
>   map.functionX();

What do you mean when you say base class?  Do you mean main application
window class?

What is the relationship between this base class and the Map class?  Are
they both derived from QWidget or a subclass thereof?

What function does the above code appear in?  Is it the base class
constructor, its update() function, or something else?

> What I need is to include "Map map(mapFrame)" in my base 
> class header file as an attribute

Add "Map* map;" to the class definition, probably as a protected member
variable.  Then initialize it in the constructor, similar to the
following:

MyClass::MyClass(QWidget* parent):
QWidget(parent),
map(new Map(mapFrame))
{...}

or:

MyClass::MyClass(QWidget* parent):
QWidget(parent)
{map = new Map(mapFrame); ...}

> mapFrame is the name of the frame generated by and then promoted under

> Designer.

Well, that means mapFrame is a Map* already present in the generated UI
class.  You won't need to construct it yourself.  Just access it like
any of the other parts of your Designer-generated user interface.

-- 
Andy Goth
<amgoth at link.com>




More information about the Qt-interest-old mailing list