Results 1 to 15 of 15

Thread: Qt Coordinate System and the Graphics View Framework

Hybrid View

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

    Default Re: Qt Coordinate System and the Graphics View Framework

    Did you try setting an inverted rectangle (starting from negative vertical values and ending at 0 or starting at positive vertical value and ending at 0 or negative) as the scene rect? This way you wouldn't have to scale anything.

  2. #2
    Join Date
    Jun 2008
    Posts
    2
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Qt Coordinate System and the Graphics View Framework

    Hey, thanks for that reply. N my apologies for replying back late ...
    Well, if I invert the scene rectangle, all my points, lines and polygon shapes drawn on it get inverted too. By scaling the view scale(1,-1) I get what I want, like showing proper coordinates on the screen, except only for QGraphicsPixmapItem and QGraphicsTextItem (They get drawn inverted).
    The kludge that I adopted worked for me. I transformed the pixmap used in QGraphicsPixmapItem using QTransform. So now it is shown properly onto the canvas. BUT, if i use QGraphicsItem::ItemIgnoresTransformations flag (To keep the picture from changin when the zoom level is changed), the picture just disappears! I dont know why and I have not been able to solve this issue as well...

    Is there something wrong with the coordinate system (s) set for scene, view and/or the items in Qt???

  3. #3

    Default Re: Qt Coordinate System and the Graphics View Framework

    has anyone managed to figure out if there is a good way to rotate/translate the coordinate system so that when drawing angles, zero degrees is up and value increase clockwise instead of zero degrees to the right and values increase counter-clockwise?

  4. #4
    Join Date
    Feb 2012
    Posts
    1
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Thumbs up Re: Qt Coordinate System and the Graphics View Framework

    I have found the solution.
    Use a QGraphicsItemGroup to contain the text items. Use the group to set coords, scales and rotation. The text items ignores the transformations.
    For example:

    Qt Code:
    1. grp->addToGroup(text);
    2. text->setFont(font);
    3. text->setPos(0,0);
    4. text->setFlag(QGraphicsItem::ItemIgnoresTransformations);
    5. grp->setPos(x,y);
    To copy to clipboard, switch view to plain text mode 


    Pay attention that the text item must be added to group before his setting his coordinates, since coordinates of the sub-item are relative to the parent item, BUT when adding the item to the group his coords relative to the scene are preserved.

    Hope that helps.

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.