Results 1 to 6 of 6

Thread: QGraphicsItem disappeare during rotation around Qt::XAxis

  1. #1
    Join Date
    Dec 2008
    Location
    Czech
    Posts
    44
    Thanks
    2
    Thanked 8 Times in 8 Posts
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11

    Default QGraphicsItem disappeare during rotation around Qt::XAxis

    Hi,
    I can't find the reason, why my object disappearing during transformation around the XAxis.
    I am showing here the short code which better expain what I mean.
    When I use QTransform on the scene and rotate the view, then if i use high angle the QGraphicsRectItem disappeare.
    Or if I make the view window height bigger, which anybody who would help me can try in this small app.


    Qt Code:
    1. #include <QApplication>
    2. #include <QGraphicsView>
    3.  
    4.  
    5. int main(int argc, char **argv)
    6. {
    7. QApplication app(argc, argv);
    8.  
    9. scene.addRect(QRectF(0,0,100,100), QPen(), QBrush(QColor(Qt::red)));
    10. QGraphicsView view(&scene);
    11. view.show();
    12.  
    13. QTransform transform;
    14. transform.rotate(80, Qt::XAxis);
    15. view.setTransform(transform);
    16.  
    17. return app.exec();
    18. }
    To copy to clipboard, switch view to plain text mode 
    Last edited by jpn; 18th January 2009 at 21:56. Reason: missing [code] tags

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

    Default Re: QGraphicsItem disappeare during rotation around Qt::XAxis

    I can see the item just fine. Bear in mind that graphics items are flat, if you rotate them 90 deg. they will disappear because their z size is 0.

  3. #3
    Join Date
    Dec 2008
    Location
    Czech
    Posts
    44
    Thanks
    2
    Thanked 8 Times in 8 Posts
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11

    Default Re: QGraphicsItem disappeare during rotation around Qt::XAxis

    Hi,
    did you try to change window size? if I make it vertically bigger the item disappear and again appear when i make the window smaller.
    If you tried it and you still can see it then the problem will be somewhere else, but I have no idea where. I was trying on the different comps with kubuntu and and also on windows. The problem was on all of them.

  4. #4
    Join Date
    Aug 2008
    Posts
    2
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QGraphicsItem disappeare during rotation around Qt::XAxis

    Hi, you should know what really you want to do. If you only want to rotate the rect, just use QGraphicsItem::rotate(). The transform will rotate the whole coordinate.

  5. #5
    Join Date
    Dec 2008
    Location
    Czech
    Posts
    44
    Thanks
    2
    Thanked 8 Times in 8 Posts
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11

    Default Re: QGraphicsItem disappeare during rotation around Qt::XAxis

    Hi,
    the code above is just simple example to demonstrate what I mean. I am doing chessboard, so there should be option to zoomin and out and to rotate it. But then is coming the problem which I described above.

    Radek

  6. #6
    Join Date
    Dec 2008
    Location
    Czech
    Posts
    44
    Thanks
    2
    Thanked 8 Times in 8 Posts
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11

    Default Re: QGraphicsItem disappeare during rotation around Qt::XAxis

    so looks like it was a bug, i have tried on qt 4.5 and the transformation is fine

Similar Threads

  1. Problem with rotation of QGraphicsItem
    By ashishsaryar in forum Qt Programming
    Replies: 2
    Last Post: 10th July 2008, 15:03
  2. rotation of an animated QGraphicsItem
    By darksaga in forum Qt Programming
    Replies: 9
    Last Post: 9th September 2007, 08:11

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.