[Qt-interest] setSceneRect vanished my items from GraphicsView :(

Enrico Ros enrico.qt at email.it
Mon Jul 13 17:11:23 CEST 2009


On Sunday 12 July 2009 13:20:11 Usman Ajmal wrote:
> Thanks Enrico but you may see that some of your rectangles are not showing
> up fully, meaning you can't see some of the rectangles' bottom and right
> parts. Also, the left and top part of your GraphicsView are white. Isn't it
> abnormal?

It's all ok. It's just becase I reproduced the same conditions you were 
writing about in your previous post.

The scene rectangle had the top-left corner on -360, -256 and the rects had 
the left and top coordinates non-negative, so it's normal you see white on the 
top and left areas.

> I think there is some thing wrong with my bounding rectangle but i couldn't
> understand the relation between bounding rectangle and setSceneRectangle
> even by viewing the Mice Collider examply of Trolltech.

You have to read carefully and understand the GraphicsView framework 
documentation, like http://doc.qtsoftware.com/4.6-snapshot/graphicsview.html .

1. Take a white sheet of paper, that is your scene. Write on the top-left and 
bottom-right corners 2 coordinates, like (0,0) and (400, 800) [note, they can 
be even negative numbers]. This is the space you can "view" and every point 
inside has a coordinate in the given range.

2. Take smaller chunks of paper and choose the anchor. For QGraphicsRect items 
the anchor is on top left. Usually you'll find the anchor on top-left or 
center of the item.

3. You can move the item (the 'anchor point') and the item will be visible  if 
you're inside the sheet of paper.

The best approach here is to have a fixed bounding rectangle and to move 
('setPos'), scale, rotate or 'transform' the item in some way. There are even 
helpers for moving items with the mouse (see QGraphicsItem::setFlags) to save 
you work.

Keep trying, it will be rewarding ;-)

Enrico Ros

--

 
 
 --
 Caselle da 1GB, trasmetti allegati fino a 3GB e in piu' IMAP, POP3 e SMTP autenticato? GRATIS solo con Email.it http://www.email.it/f
 
 Sponsor:
 OLTREMARE HOTELS:
* Cerchi un hotel a Riccione, Rimini o Misano Adriatico ? Visita il sito www.rivieraparkhotels.it . Gli alberghi dei parchi divertimento
 Clicca qui: http://adv.email.it/cgi-bin/foclick.cgi?mid=9349&d=13-7



More information about the Qt-interest-old mailing list