Results 1 to 5 of 5

Thread: Strange behavior of GraphicsView when change the scale of affine transform.

  1. #1
    Join Date
    Sep 2010
    Posts
    654
    Thanks
    56
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Strange behavior of GraphicsView when change the scale of affine transform.

    I had this code for affine transform to draw on a QWidget.
    AFT.reset();
    AFT.translate(scrollh, scrollv); // pixelxs h from 0 to middle of widget , pixelxs v from 0 to middle of widget
    AFT.scale(scalx, -scaly); // scale relation betwen my world bounds in cartersian coordinates and the width / heigth of the widget.
    AFT.translate(-xc, -yc); // real coordinates of the center


    Now I'm going to use Qgraphicsview / Qgraphicscene.
    I have a widget extends Qgraphicsview with a Qgraphicscene. created into it.
    I appy the transform to the view. (setTransform (AFT);

    I draw my elements. OK, the initial view is centered and this 'world' entitities are drawed right.

    If I increase or decrease the scalx scaly, the redraw shows me a world not centered, with an arbitratious center choosen.
    Only when the scale is bigger (like a zoom - ) than neccesary the 'world' is centered.

    (My code worked well when it was applied to a qwidget/paint )
    Qgraphicsscene has not limits (that is to say I have not SceneRect)

    Any idea ? It is as Qgraphicsscene was doing something -.....
    Thanks

  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: Strange behavior of GraphicsView when change the scale of affine transform.

    What is the effect you want to obtain?
    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.


  3. #3
    Join Date
    Sep 2010
    Posts
    654
    Thanks
    56
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Strange behavior of GraphicsView when change the scale of affine transform.

    Always centered of course.
    Here you are a video (avi file, can you see it ?)
    Attached Files Attached Files
    Last edited by tonnot; 26th September 2011 at 16:23.

  4. #4
    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: Strange behavior of GraphicsView when change the scale of affine transform.

    What should be centered related to what?
    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
    Sep 2010
    Posts
    654
    Thanks
    56
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Strange behavior of GraphicsView when change the scale of affine transform.

    Solved with :

    setTransformationAnchor(QGraphicsView::NoAnchor);
    setSceneRect(rectf); // the limits of 'my world'

    But I dont undertand why ...
    I think that if you have an affine transform applied nothing more would be needed, but ...

    There is 'hidden' actions inside this two options...
    Thanks
    Last edited by tonnot; 26th September 2011 at 23:07.

Similar Threads

  1. setCellWidget - strange behavior
    By Archa4 in forum Newbie
    Replies: 5
    Last Post: 28th April 2011, 08:26
  2. strange behavior of paintEvent
    By hashb in forum Qt Programming
    Replies: 3
    Last Post: 30th August 2010, 07:48
  3. QAudioInput example strange behavior
    By m15ch4 in forum Qt Programming
    Replies: 0
    Last Post: 13th August 2010, 06:55
  4. Strange behavior of QSqlTableModel
    By venomj in forum Qt Programming
    Replies: 0
    Last Post: 13th January 2010, 03:29
  5. scrollbars strange behavior
    By siniy in forum Qt Programming
    Replies: 6
    Last Post: 29th December 2006, 10:27

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.