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

Usman Ajmal uzmanajmal at gmail.com
Mon Jul 13 17:47:11 CEST 2009


 Thanks Enrico i got the problem solved. I was actually changing location of
rectangle in the RectMap::paint() function. That was creating the main
problem. Now everything is just appearing fine because now i am changing
setPos to display my new rectangles.  :)

But now i have problem with making my items clickable or hightlighted when
hovered. I showed my code here:
http://www.qtcentre.org/forum/f-newbie-4/t-mouse-hovering-or-press-event-not-working-22438.html

Anyways thanks for the nice example though. It made things clear.

--
Usman

  On Mon, Jul 13, 2009 at 8:11 PM, Enrico Ros <enrico.qt at email.it> wrote:

> 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
>  _______________________________________________
> Qt-interest mailing list
> Qt-interest at trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-interest
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20090713/ab4ac5f0/attachment.html 


More information about the Qt-interest-old mailing list