[PyKDE] QColorGroup

Pete Ware ware at cis.ohio-state.edu
Fri Jan 14 20:30:29 GMT 2000


Phil Thompson <phil at river-bank.demon.co.uk> writes:

> Pete Ware wrote:
> >
> > Wow, it's because a QPalette puts the foreground as the first object:
> >
> > class Q_EXPORT QColorGroup                              // color group class
> > {
> > public:
> >     ...
> > private:
> >     QColor fg_col;
> >     QColor bg_col;
> >     ...
> > };
> >
> > QColorGroup  color_group;
> >
> > "color_group" is the same memory location as the first element
> > color_group.fg_col.
> >
> > --pete
>
> Which implies that C++ creates a temporary copy of an object when it
> returns a reference to it (and it's re-using the same memory in this
> case).
No.  It returns the address of the object.

Here is what I think is going wrong:

            0xffaabbcc
color_group:|--------|
     fg_col |        |
            |        |
            |        |
            |--------|
     bg_col |        |
            |        |
            |        |
            _________|

The color_group is layed out in memory.  "fg_col" is the first element
(and it is not a pointer).  Then &color_group.fg_col == &color_group

--pete




More information about the PyQt mailing list