Results 1 to 3 of 3

Thread: Creating a new QPixmap out of a rotated QGraphicsPixmapItem

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Mar 2010
    Posts
    1
    Qt products
    Qt4
    Platforms
    Windows

    Default Creating a new QPixmap out of a rotated QGraphicsPixmapItem

    Hi all,

    I have set up a QGraphicsScene & QGraphicsView and added a QGraphicsPixmapItem that has a square bounding QRect. The center of the QPixmap is at the scene center.
    i.e.

    Qt Code:
    1. QGraphicsView* graphicsView;
    2. QGraphicsScene* graphicsScene = new QGraphicsScene();
    3. QPixmap pic = QPixmap(":/new/pic.jpg").scaled(QSize(100,100));
    4. QGraphicsPixmapItem* bg = graphicsScene->addPixmap(pic);
    5. bg->setPos(-50,-50);
    6. graphicsView->setScene(graphicsScene);
    7. graphicsView->fitInView(bg);
    To copy to clipboard, switch view to plain text mode 

    This allows the pixmap to fill the entire view so I don't see any whitespace. The problem comes when I rotate by calling rotate() on the QGraphicsView which contains pixmap;

    Qt Code:
    1. int degrees;
    2. graphicsView->rotate(degrees);
    To copy to clipboard, switch view to plain text mode 

    Where degrees is some value I get from the user.

    The view rotates as I would expect, creating a "diamond" from the rotated square QPixmap. What I would like to do now is to make a square again by essentially taking the inset square of the image, and filling the graphicsScene with that new image.


    I appreciate any ideas anyone has for how to do this.
    Thank you.
    Last edited by Aondiar; 15th March 2010 at 05:09.

Similar Threads

  1. QGraphicsTextItem sharpness when rotated
    By martinn in forum Qt Programming
    Replies: 3
    Last Post: 26th February 2010, 12:13
  2. drawing series of rotated ellipses
    By qtn00b in forum Newbie
    Replies: 1
    Last Post: 17th December 2009, 01:51
  3. How draw a rotated text in a QPainterPath?
    By iw2nhl in forum Qt Programming
    Replies: 6
    Last Post: 17th August 2007, 18:55
  4. Replies: 2
    Last Post: 3rd November 2006, 22:20
  5. rotated labels
    By jayw710 in forum Qt Programming
    Replies: 2
    Last Post: 11th April 2006, 17:47

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.