Results 1 to 8 of 8

Thread: again QGraphicsView + steady(unmoved) Item

  1. #1
    Join Date
    Dec 2009
    Posts
    50
    Qt products
    Qt4
    Platforms
    Windows
    Thanks
    9

    Default again QGraphicsView + steady(unmoved) Item

    Hello Everybody

    I have a scene with several items on it. I applay transformations on the scene ( move, zoomin=scale, rotation and so on ).

    But I want to have some item( some cotroll like button or may be logo ) alway be at the top-right corner of the scene and has the same size and ignores any transformations.

    Qt Code:
    1. theItem.setFlag(QGraphicsItem::ItemIgnoresTransformations, true);
    To copy to clipboard, switch view to plain text mode 
    works good except the case: if I scale or move the scene, theItem moves as well ( make sence, it keeps it's position on the scne ).

    So how can I make Item unmovable in viewport() coordinate system?

    Generel task is to create some controll( like button ) and put it on top of the scene. May be to use item is not very efficient here?

    Thank you!

  2. #2
    Join Date
    Jan 2006
    Location
    Belgium
    Posts
    1,938
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Thanked 268 Times in 268 Posts
    Wiki edits
    20

    Default Re: again QGraphicsView + steady(unmoved) Item

    I guess you should put that item (and its size) relative to the view instead of absolute in the scene.

    http://doc.qt.nokia.com/4.6/graphics...rdinate-system

  3. #3
    Join Date
    Dec 2009
    Posts
    50
    Qt products
    Qt4
    Platforms
    Windows
    Thanks
    9

    Default Re: again QGraphicsView + steady(unmoved) Item

    Yes. I understand that.
    But how exactly should I do it? The only way I see so far is to do it manually every time I apllay scale to the scene.
    Any other ways?

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,376
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Thanks
    4
    Thanked 5,019 Times in 4,795 Posts
    Wiki edits
    10

    Default Re: again QGraphicsView + steady(unmoved) Item

    Quote Originally Posted by medved6 View Post
    So how can I make Item unmovable in viewport() coordinate system?
    You can make it a widget and place it inside the view (but not the scene). Then it will be immune to all view transformations (you're transforming the view, not the scene).
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  5. #5
    Join Date
    Dec 2009
    Posts
    50
    Qt products
    Qt4
    Platforms
    Windows
    Thanks
    9

    Default Re: again QGraphicsView + steady(unmoved) Item

    But is there any way to solve my issue with Item(not with wiget) ?
    The reason I'm asking: I have some advanced Item and I want to make it steady.

  6. #6
    Join Date
    Oct 2009
    Location
    Mexico
    Posts
    81
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    6
    Thanked 10 Times in 10 Posts

    Default Re: again QGraphicsView + steady(unmoved) Item

    you can draw directly in the view, using the function QGraphicsView::drawForeground()
    please check the post:
    http://www.qtcentre.org/threads/2745...ht=#post130114

    to draw a item directly in the view, use the paint() funtion from the Items. using the painter provided for the QGraphicsView subclass.

  7. #7
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,376
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Thanks
    4
    Thanked 5,019 Times in 4,795 Posts
    Wiki edits
    10

    Default Re: again QGraphicsView + steady(unmoved) Item

    Quote Originally Posted by medved6 View Post
    But is there any way to solve my issue with Item(not with wiget) ?
    The reason I'm asking: I have some advanced Item and I want to make it steady.
    Yes, you have to move the item on the scene every time you transform the view.

    Quote Originally Posted by ecanela View Post
    you can draw directly in the view, using the function QGraphicsView::drawForeground()
    This draws in scene coordinates so it's practically useless here especially if one needs to handle some input events with the item.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  8. The following user says thank you to wysota for this useful post:

    medved6 (5th September 2010)

  9. #8
    Join Date
    Dec 2009
    Posts
    50
    Qt products
    Qt4
    Platforms
    Windows
    Thanks
    9

    Default Re: again QGraphicsView + steady(unmoved) Item

    Thank you!
    It seems like I'm going to implement my view in the way that it will take care about all steady Items manually.

Similar Threads

  1. QGraphicsView + steady Items
    By medved6 in forum Qt Programming
    Replies: 2
    Last Post: 25th August 2010, 19:20
  2. Replies: 1
    Last Post: 16th December 2009, 02:48
  3. QGraphicsView to follow Item?
    By sven-kt in forum Qt Programming
    Replies: 5
    Last Post: 25th August 2009, 08:40
  4. MDI display Item in QGraphicsView
    By wisconxing in forum Qt Programming
    Replies: 1
    Last Post: 7th November 2008, 00:11
  5. QGraphicsView and item focus
    By Micawber in forum Qt Programming
    Replies: 3
    Last Post: 22nd June 2007, 20:36

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.