Results 1 to 2 of 2

Thread: Having problems with transformations

  1. #1
    Join Date
    May 2007
    Location
    Lublin, Poland
    Posts
    345
    Thanks
    40
    Thanked 8 Times in 4 Posts
    Qt products
    Qt3 Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Having problems with transformations

    Hi guys,

    I have implemented my own QGraphicsScene::drawBackground(QPainter* ....) method.
    I draw a map in that method, but before drawing, to get the correct image, I had to make these transformations:
    (*****)
    Qt Code:
    1. ....
    2. painter->translate(550,300);
    3. painter->rotate(180);
    4. painter->scale(-3.37778,3.37778);
    5.  
    6. painter->drawRect(m_rectangle);
    7. ...
    To copy to clipboard, switch view to plain text mode 
    and then I got the correct map drawn. In this method I also draw same rectangles.

    Now, after I have my map and the rectangles drawn in the drawBackground(QPainter*..) I need to add some QGraphicsTextItems in the center of that rectangles, but I have problems with finding the transformation for the items to draw them in the correct place.
    Now I need to add a QGraphicsTextItem in the center of the "m_rectangle";

    I tried using the same transform (*****) for my items (like item->translate()...etc), but they I drawn in the wrong place.

    How can I get the QGraphicTexItem added in the center of the m_rectangle(which is drawn in the drawBackground(QPainter*) ) ??

    I do appreciate any ideas.
    Thank you

    Maverick
    Qt allows you to use everything you want
    wysota
    --------------------------------------------------------------------------------
    #if defined(Q_OS_UNIX) && defined(QT_DEBUG)
    abort(); // trap; generates core dump
    #else
    exit(1); // goodbye cruel world
    #endif

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

    Default Re: Having problems with transformations

    You can map rectangle between different matrices using QMatrix::map(). It's just a matter of picking the right pair of matrices.

Similar Threads

  1. Replies: 2
    Last Post: 8th March 2007, 22:22
  2. Problems using a DLL
    By prosass in forum Newbie
    Replies: 7
    Last Post: 6th March 2007, 17:45
  3. Problems building mysql plugin for Qt 4.1.2 on windows XP
    By Philip_Anselmo in forum Installation and Deployment
    Replies: 3
    Last Post: 17th May 2006, 15:38
  4. QT4 Plugins - problems, problems
    By NormanDunbar in forum Qt Programming
    Replies: 6
    Last Post: 9th May 2006, 15:39
  5. problems with Opengl
    By SlawQ in forum Qt Programming
    Replies: 4
    Last Post: 12th February 2006, 22:49

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.