Results 1 to 5 of 5

Thread: QPixmap xx.scaledToWidth dont Scale but load...

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    May 2006
    Posts
    788
    Thanks
    49
    Thanked 48 Times in 46 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default QPixmap xx.scaledToWidth dont Scale but load...

    I wand to scale an image on my CMS is this to much work if scale slot is a qslider

    or is int width QSize and not pixel?

    scaledToWidth ( int width, Qt::TransformationMode mode = Qt::FastTransformation ) const

    Qt Code:
    1. /* header */
    2. private:
    3. Gui_Image( QWidget* = 0 );
    4. QImage image;
    5. QPixmap myPixmap;
    6. QSize actual;
    7. /* header ..... */
    8.  
    9. /* i load image */
    10.  
    11. fileName = OpenFile("Image (*.png)");
    12.  
    13. if (!fileName.isEmpty()) {
    14. connect(horizontalSlider, SIGNAL(valueChanged(int)), this, SLOT(ModpicsChanged(int)));
    15. ...
    16. centrale->setPixmap(QPixmap::fromImage(image));
    17. ...
    18. centrale->adjustSize();
    19.  
    20. actual = centrale->pixmap()->size();
    21. ...
    22. horizontalSlider->setSliderPosition(wi);
    23. ...
    24. }
    25. /* ..... */
    26.  
    27. void Gui_Image::ModpicsChanged(int newvalue_w) /* int from QSlider 20px steeps */
    28. {
    29. ...
    30. myPixmap = QPixmap::fromImage(image);
    31. myPixmap.scaledToWidth(newvalue_w,Qt::FastTransformation);
    32. centrale->setPixmap(myPixmap); /* label */
    33. centrale->adjustSize(); /* label */
    34. actual = centrale->pixmap()->size();
    35. ...
    36. }
    To copy to clipboard, switch view to plain text mode 
    Last edited by jacek; 25th June 2006 at 22:29. Reason: removed unrelevant code and fixed indentation

Similar Threads

  1. QPixmap and HBITMAP
    By ToddAtWSU in forum Qt Programming
    Replies: 1
    Last Post: 21st June 2006, 16:24

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.