[Qt-interest] Qt/C++ working with graphicsview (Ross Driedger)

Stephen Deetz stephendeetz at chibardun.net
Sun Jan 24 21:17:52 CET 2010


Thanks, Ross.

Re: Qt/C++ working with graphicsview (Ross Driedger)

>> There is no point in deriving a new class unless you add  
>> something new to it.

I agree, but the docs make it seem necessary to reimplement the paint
method. I can paint otherwise, but really want to use QGraphicsView Show to
show the graphics items.

>> I gather from your terminology that you have some Java experience.

I programmed in Delphi for 10 years and C 10 years before that.  I feel like
2 years old having to ask these simple questions. :)

>> Look up 'initiation lists' in a good C++ reference.

Isn't this just short hand for the assignments (m_X = x, etc...) I'm doing?
I realized there was short hand, just didn't know the syntax off the top of
my head.  

I thought QGraphicsEllipseItem::QGraphicsEllipseItem( m_X, m_Y, m_W, m_H,
parent ); was the proper way to call the super class, but this won't happen
with just an initialization list, correct?

In a Delphi constructor, one would call inherited() (super in java)
immediately to make certain the inheritance chain is executed.  In C++, the
proper way is InheritedObject::InheritedObject, no?

>>Bounding Rect

Sorry if my earlier question was unclear.

My question: What does Qt use boundingRect for?

Cordially,

Stephen Deetz

------------------------------

Message: 3
Date: Sun, 24 Jan 2010 12:34:48 -0500
From: Ross Driedger <ross at earz.ca>
Subject: Re: [Qt-interest] Qt/C++ working with graphicsview
To: qt-interest at trolltech.com
Message-ID: <5B698222-59B4-4A52-9EE8-A31C90F21A03 at earz.ca>
Content-Type: text/plain; charset="us-ascii"


On 24-Jan-10, at 11:32 AM, qt-interest-request at trolltech.com wrote:

> Message: 2
> Date: Sun, 24 Jan 2010 09:30:28 -0600
> From: "Stephen Deetz" <stephendeetz at chibardun.net>
> Subject: [Qt-interest] Qt/C++ working with graphicsview.
> To: <qt-interest at trolltech.com>
> Message-ID: <005a01ca9d0a$28b477b0$7a1d6710$@net>
> Content-Type: text/plain; charset="us-ascii"
>
> Trying to get used to Qt/C++ by working with graphicsview.
>
>
>
> Main question: How does a scene connect to an item for mouse events?

Until you fix the C++ issues, it is pointless to sweat the Qt details.

> Other questions:
>
> 1)  Am I using the inherited stuff correctly?

No.  There is no point in deriving a new class unless you add  
something new to it.  The coordinates are stored in the subclass.

> a.  Calling the super classes.

No.  Look up 'initiation lists' in a good C++ reference.

> b.  Virtual keyword needed for subclass only if planning on making
> descendents?

No.  Look up 'late binding' in a good C++ reference.  I gather from  
your terminology that you have some Java experience.  Java does not  
have this issue.

> 2)  I think I know what bounding rect is, but why is it needed if  
> shape is
> used for collisions?

??

I don't understand your question.  I do some fairly intricate graphics  
(music notation) and need to check for more than collisions

> 3)  Qreal to int conversion. Is this a problem?

Everything to the right of the decimal will be lost.  A good compiler  
will warn you of this if you have the warnings on -- which you should.

Ross

"Sometimes I think the surest sign that intelligent life exists  
elsewhere in the universe is that none of it has tried to contact us."
Bill Waterson (Calvin & Hobbes)

Ross Driedger
ross_at_earz.ca









More information about the Qt-interest-old mailing list