Has anyone made scrollarea zoom with widget



  • The scrollarea works with a label, both scrolling and zooming. Using a widget it will scroll, but not zoom. The problem seems to be with:

    mageLabel->resize(scaleFactor * imageLabel->pixmap()->size());
    

    Widget does not resize.

    Has anyone found what changes must be made to widget to get it to work? Label has a method to set the contents scaleable, but widget has no such method.


  • Lifetime Qt Champion

    Hi,

    You should show the complete setup of your widgets.


  • Qt Champions 2017

    Hi
    I assume its the scrollarea i help with so im pretty sure you are using a layout.
    When a QWidget is controlled by a layout,
    setGeometry and resize are ignore as layout controls sizes.
    You can however use
    setMinimumSize(QSize( w,h ) ) to make the widget be bigger.



  • @mrjj Thanks. I thought it had something to do with the layout. I changed the minimumSize from 20,000x10,000 to 200x100, all of the pixmap was visible and zooming worked, sorta--lost the scrollbars. However, headway has been made.

    In looking at the QLabel source, I noted that on line 1094 the pixmap is converted to an QImage object scaled and converted back to a pixmap. I am assuming that it was done for performance reasons.



  • @ofmrew Just a note for others interested in source code, use wobog because it will help you navigate through the code. Nice!



  • Hello Everyone,
    I'm learning Qt as a beginner, I stuck in one query that how can i set image in Scrollarea UI??


  • Qt Champions 2017

    @Prince_0912
    Hi and welcome
    I you can place a QLabel on it and set its Pixmap property to an image.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.