Results 1 to 3 of 3

Thread: Rotating the GraphicsItem while translating

  1. #1
    Join Date
    May 2008
    Posts
    4
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Lightbulb Rotating the GraphicsItem while translating

    Hi !!!! ,

    I am implementing a simulator in Qt of objects moving on a table.
    Hence it is required that I should also have an option to rotate the object while translating it.
    Both can be done exclusively but how can we achieve it together.
    I created a Graphics item and set its flag ItemIsMovable true and then in the keypressevent
    if I get an 'r' pressed while the left button is pressed then I should rotate the object .
    But this doesnt seem to work.
    My object gets created always from the original position and since I use a static variable to store whether the mouse key is pressed or not, I can do this if I have only one item or I should create a array of the no of objects I should add.

    Any help is greatly appreciated in the project!!
    Thanks in advance.

  2. #2
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: Rotating the GraphicsItem while translating

    Quote Originally Posted by ashishrai View Post
    My object gets created always from the original position and since I use a static variable to store whether the mouse key is pressed or not, I can do this if I have only one item or I should create a array of the no of objects I should add.
    So why do you use a static variable? Why not an ordinary non-static member variable?
    J-P Nurmi

  3. #3
    Join Date
    Oct 2006
    Location
    New Delhi, India
    Posts
    2,467
    Thanks
    8
    Thanked 334 Times in 317 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Rotating the GraphicsItem while translating

    Why cant both be done at same time ??

    You can set the matrix for the graphics view. See QGraphicsView::setMatrix() and QGraphicsView::setTransform()

    u can combine the matrix to get the desired effect.
    Also I remember translation and rotation happening in Arthur PLugin example I guess/. Check the demos.

    Hope this helps.

Similar Threads

  1. problem translating & rotating text
    By impeteperry in forum Qt Programming
    Replies: 9
    Last Post: 3rd July 2006, 19:17

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.