Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Specificially position pixmap in QLabel in QScrollArea or other solutions



  • I am trying to render only visible parts of a map which works fine. However I can't get my pixmap to be in the location I need it to be on my label. My label is bigger to retain the Scrollbars and show the size of the actual map with them.
    Is there a way to tell the label where the pixmap should sit? I have read that maybe a QGraphicsView would be better but haven't yet looked into it much.


  • Moderators

    @Meeuxi said in Specificially position pixmap in QLabel in QScrollArea or other solutions:

    Is there a way to tell the label where the pixmap should sit? I have read that maybe a QGraphicsView would be better but haven't yet looked into it much.

    No, not for a label. Derive a simple QWidget and paint your wanted region of the pixmap in the paintEvent override instead.



  • @kshegunov So you're suggesting I reuse what I have already painted and only repainting the visible parts? I'm not sure I'm understanding you.
    What I would like is to only paint the visible part of the image for each movement in the ScrollBar and everything else should be empty. However my Label needs to be bigger to get the ScrollBars to represent my entire image. Now I need my image to be positioned where the QScrollArea is showing.
    WIth QWidget I would place a QWidget in QScrollArea, resize it and then paint directly on my widget in the area I want? Is it possible to start drawing in a specific location there?


Log in to reply