Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Resize width of QPixmap without scale
Qt 6.11 is out! See what's new in the release blog

Resize width of QPixmap without scale

Scheduled Pinned Locked Moved General and Desktop
qpixmap
4 Posts 2 Posters 5.0k Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    Blakoli
    wrote on last edited by
    #1

    Hi,

    Hello is it possible to resize a QPixmap without auto rescale of the height ?

    I tryed many way but nothin seems to work.

    If not i will have to load every single picture modified in paint or something like that...

    Of course i spent time searching on the web but nobody asked this question already.
    I'm pretty new in Qt Framework but i will learn as fast as possible.
    Thanks in advance

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi and welcome to devnet,

      Do you mean QPixmap::scaled using Qt::IgnoreAspectRatio ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • B Offline
        B Offline
        Blakoli
        wrote on last edited by
        #3

        Ho yeah, thanks alot.
        I did not check the scaled method, i was trying something like resize or setGeometry.
        It work fine !

        Here is how look my slot now:

        void MainWindow::resizeRessort(int resizeWidth)
        {
            int newWidth=(int)(((resizeWidth+1)/100.0)*myWidth);
            QSize myRessortSize(newWidth,myHeigth);
        
            QPixmap myNewRessort =myRessort->scaled(myRessortSize,Qt::IgnoreAspectRatio,Qt::SmoothTransformation);
        
        
            myLabel->setPixmap(myNewRessort);
        }
        

        Hope it can help

        Thanks

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          You're welcome !

          Since you have it working now, please update the thread title prepending [solved] so other forum users may know a solution has been found :)

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved