Results 1 to 7 of 7

Thread: how to redraw cube to rectangle

  1. #1
    Join Date
    Sep 2008
    Location
    Bangalore
    Posts
    659
    Thanks
    116
    Thanked 42 Times in 41 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default how to redraw cube to rectangle

    hi friends/experts,
    i attach a .png image which i like to draw on screen on QGraphicsView as an Item ...
    is it possible to animate it as if user mouse press this will repaint reducing to rectangle and release will take it to original form as like padnavigator example item which expands and contract ...
    can any one please give me some useful suggestion as it is able work or not and how can i do that as erasing the lower part of the area on timeline forward and redrawing in timeline backward ...
    please suggest me how can i plan this ...
    Attached Images Attached Images

  2. #2
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: how to redraw cube to rectangle

    Hi,

    private member bool isDown in your item, listening to mouse press/release event -> changing isDown and call update. In your paint directive handle isDown.

    Lykurg

  3. #3
    Join Date
    Sep 2008
    Location
    Bangalore
    Posts
    659
    Thanks
    116
    Thanked 42 Times in 41 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: how to redraw cube to rectangle

    thanks for the reply first

    Quote Originally Posted by Lykurg View Post
    Hi,

    private member bool isDown in your item, listening to mouse press/release event -> changing isDown and call update. In your paint directive handle isDown.

    Lykurg
    This property holds whether the button is pressed down.
    but i am not using a button i am using a painted cube ... as an item ...

  4. #4
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: how to redraw cube to rectangle

    Hi,

    what I meant was to create a private variable named xyz (and also it could be named isDown).

    Qt Code:
    1. ...
    2. private:
    3. bool xyz;
    4.  
    5. YourItem::mousePressEvent(...)
    6. {
    7. xyz = true;
    8. update();
    9. }
    10.  
    11. YourItem::mouseReleaseEvent(...)
    12. {
    13. xyz = false;
    14. update();
    15. }
    16.  
    17. YourItem::paint(...)
    18. {
    19. if (xyz)
    20. ...//draw flat
    21. else
    22. ...//draw 3d
    23. }
    To copy to clipboard, switch view to plain text mode 
    Last edited by Lykurg; 10th February 2009 at 13:54. Reason: spelling error

  5. The following user says thank you to Lykurg for this useful post:

    wagmare (10th February 2009)

  6. #5
    Join Date
    Sep 2008
    Location
    Bangalore
    Posts
    659
    Thanks
    116
    Thanked 42 Times in 41 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: how to redraw cube to rectangle

    thanks now i got it ...
    and how can i erase the side portion of an item like the cube pressed in timeline signals is there any option in QpaintEvent to erase the particular render area and redraw
    Last edited by wagmare; 10th February 2009 at 14:09.

  7. #6
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: how to redraw cube to rectangle

    There my deeper knowledge is gone, but I think that to handle erase etc for such an easy item (as shown in the attached image) is to much. Just draw the entire item in the paint-method depending on the state. At the beginning of paint() Qt deletes all previous content by default. That is - as I guess - better in performance than to erase (and then you surely want to move the blue rect...).

    Lykurg

  8. #7
    Join Date
    Sep 2008
    Location
    Bangalore
    Posts
    659
    Thanks
    116
    Thanked 42 Times in 41 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: how to redraw cube to rectangle

    hahaha ... i just ask is there any possiblity ..thanks i will do the same .. i just move the blue item using translate so it will overdraw the below lines ..

Similar Threads

  1. Rotating a rectangle about its origin
    By babu198649 in forum Newbie
    Replies: 5
    Last Post: 25th October 2008, 12:24

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.