Results 1 to 10 of 10

Thread: rotate an image

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #6
    Join Date
    Feb 2012
    Location
    Armenia/Yerevan
    Posts
    400
    Thanks
    15
    Thanked 16 Times in 15 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11

    Default Re: rotate an image

    Although I could rotate the inner image with the code below, the sad point is that, the background image always fit inside the inner QLabel. But, what I need is to rotate both the QLabel and the image simultaneously. or it will be better not to use QLabel at all this way. can I only load an extra image inside the outer frame background image and try to rotate it? I need help please.

    Qt Code:
    1. QPixmap *orig_pixmap = new QPixmap();
    2. orig_pixmap->load("path-to-png");
    3. degrees++;
    4. if(degrees == 90) degrees = 0;
    5. QTransform rotate_disc;
    6. rotate_disc.translate((orig_pixmap->width()-ui->label->width())/2 , (orig_pixmap->width()-ui->label->height())/2);
    7. rotate_disc.rotate(degrees,Qt::ZAxis);
    8. QPixmap pixmap;
    9. //pixmap = orig_disc->scaled(89,89,Qt::IgnoreAspectRatio,Qt::SmoothTransformation);
    10. pixmap = orig_pixmap->transformed(rotate_disc,Qt::SmoothTransformation);
    11. ui->label->setPixmap(pixmap);
    To copy to clipboard, switch view to plain text mode 
    Last edited by saman_artorious; 26th March 2013 at 06:13.

Similar Threads

  1. Rotate a QRectF
    By whitefurrows in forum Qt Programming
    Replies: 5
    Last Post: 15th July 2009, 15:33
  2. how to rotate an image...
    By sh123 in forum Qt Programming
    Replies: 2
    Last Post: 15th January 2009, 14:59
  3. Rotate QLabel
    By shader76 in forum Newbie
    Replies: 9
    Last Post: 24th December 2007, 12:31
  4. Rotate QGraphicsPixmapItem
    By durbrak in forum Qt Programming
    Replies: 7
    Last Post: 15th April 2007, 14:51
  5. Replies: 3
    Last Post: 14th March 2007, 08:09

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.