Results 1 to 6 of 6

Thread: larger(not to scale) a exist QPixmap and paint more thing on the blank space

  1. #1
    Join Date
    Aug 2008
    Location
    Nanjing, China
    Posts
    66
    Thanks
    12
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default larger(not to scale) a exist QPixmap and paint more thing on the blank space

    QPixmap.transformed(QTransform::fromTranslate(x,y) ) did not have a good result.
    Is there a way?
    Jerry

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: larger(not to scale) a exist QPixmap and paint more thing on the blank space

    Have you tried QPixmap::scaled(), QPixmap::scaledToWidth() and QPixmap::scaledToHeight() ?

    Where do you want to put the larger QPixmap? On a QLabel? Then just have a look at QLabel::scaledContents()

  3. #3
    Join Date
    Aug 2008
    Location
    Nanjing, China
    Posts
    66
    Thanks
    12
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: larger(not to scale) a exist QPixmap and paint more thing on the blank space

    yes,i tried the scaled(), but it did not work as I wanted. It just scaled the whole picture. what i wanted is just larger the paint area and leave the origin picture unchanged.Then I will draw something on the blank area.


    Added after 32 minutes:


    Is it a complicated problem?
    Last edited by calmspeaker; 8th July 2011 at 07:19.
    Jerry

  4. #4
    Join Date
    Mar 2011
    Posts
    63
    Thanks
    11
    Thanked 5 Times in 5 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: larger(not to scale) a exist QPixmap and paint more thing on the blank space

    Well if you just want to adjust the size of the paint area it is not very complicated. Lets say that you are painting in a QWidget then in paintEvent() you can do something like this.

    Qt Code:
    1. QPixmap example;
    2. example.load("Picturepath");
    3. QSize pixmapSize = example.size();
    4. this->resize(pixmapSize);
    To copy to clipboard, switch view to plain text mode 

    Edit: And of course use QPainter::drawPixmap after that
    Last edited by meazza; 8th July 2011 at 07:33.

  5. #5
    Join Date
    Jan 2008
    Posts
    72
    Thanks
    3
    Thanked 4 Times in 4 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows Symbian S60

    Default Re: larger(not to scale) a exist QPixmap and paint more thing on the blank space

    Use QPainter inside paint event and draw pixmap through
    void QPainter::drawPixmap ( int x, int y, int width, int height, const QPixmap & pixmap )
    I hope it will help you...

  6. The following user says thank you to MrShahi for this useful post:

    calmspeaker (8th July 2011)

  7. #6
    Join Date
    Aug 2008
    Location
    Nanjing, China
    Posts
    66
    Thanks
    12
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: larger(not to scale) a exist QPixmap and paint more thing on the blank space

    You did help me! Thank you.
    Qt Code:
    1. QPixmap pixicon = item->icon(column).pixmap(QSize(32,32));//the origin icon
    2. QPixmap pix(32,32);//store the modified icon
    3. pix.fill(Qt::transparent);
    4. QPainter paint(&pix);
    5. paint.drawPixmap(16,16,16,16,pixicon);//bottom right paint pixicon
    6.  
    7. paint.drawLine(QPointF(12,0),QPointF(12,24));//modify the pixmap
    8. paint.drawLine(QPointF(0,12),QPointF(24,12));
    To copy to clipboard, switch view to plain text mode 
    Jerry

Similar Threads

  1. Replies: 6
    Last Post: 7th November 2010, 14:17
  2. Blank space at right side of plot
    By liversedge in forum Qwt
    Replies: 2
    Last Post: 14th August 2010, 13:02
  3. how to change the line space in QGraphicsTextItem Paint()
    By goldhappywang in forum Qt Programming
    Replies: 1
    Last Post: 22nd September 2009, 01:42
  4. Replies: 1
    Last Post: 26th July 2009, 15:08
  5. QPixmap xx.scaledToWidth dont Scale but load...
    By patrik08 in forum Qt Programming
    Replies: 4
    Last Post: 25th June 2006, 23:21

Tags for this Thread

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.