Results 1 to 3 of 3

Thread: QPixmap resize problem

  1. #1
    Join Date
    May 2008
    Posts
    15
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default QPixmap resize problem

    i have an image size 640*480, i am trying to resize it to 640*300.

    my first try was:
    QPixmap pixmap(QPixmap(imagePath));
    pixmap.scaledToHeight(300,Qt::SmoothTransformation );
    qDebug()<<pixmap.size();

    but it also change width scale.---

    then I tried
    QIcon icon;
    QSize size(640,300);
    QImage image(QImage(imagePath));
    icon.addPixmap(QPixmap::fromImage(image), QIcon::Normal, QIcon::On);
    QPixmap pixmap = icon.pixmap(size, QIcon::Normal, QIcon::On);

    qDebug()<<pixmap.size();

    same problem---
    any suggession is appreciating....thnks

  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: QPixmap resize problem

    Do you want to scale or to crop it? If you want to scale, simply call scaled() with the same width but different height.

  3. #3
    Join Date
    May 2008
    Posts
    15
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: QPixmap resize problem

    pixmap.scaled(640,300,Qt::IgnoreAspectRatio,Qt::Fa stTransformation);

    same problem.----width automatically becomes...225
    i dont know and I am stucked here....
    please help

Similar Threads

  1. Qt 4.4 QDockWidget resize problem
    By MarkSutton in forum Qt Tools
    Replies: 2
    Last Post: 27th September 2008, 08:55
  2. Replies: 1
    Last Post: 10th August 2008, 18:55
  3. QGLWidget Resize Problem
    By Sandip in forum Qt Programming
    Replies: 2
    Last Post: 28th February 2008, 06:47
  4. QGLWidget resize problem.
    By anderl in forum Qt Programming
    Replies: 2
    Last Post: 22nd January 2008, 08:57
  5. QTable resize problem with large tables
    By Robzzz in forum Newbie
    Replies: 3
    Last Post: 22nd May 2006, 14:13

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.