Yes but I have to scale it many times, so I cannot set a size for the label, because it could change many times.
In fact this is only a first step just to understand how to scale it, because after I have to scale it connecting it to a vertical bar.
Yes but I have to scale it many times, so I cannot set a size for the label, because it could change many times.
In fact this is only a first step just to understand how to scale it, because after I have to scale it connecting it to a vertical bar.
I am afraid I don't understand.
You need a label with a target size so you set that size.
If the label has scaled contents set to true, it will scale its contents.
Cheers,
_
Maybe I'm not understanding what you're saying.
If you set the size of a label, the label will remain of that size?
I think (if I have understood) that if I set a size for a label and after I scale the pixmap,
the only thing that will scale will be the pixmap, not the label that has a fixed size. Am I wrong?
So my question is:
I have a mainwindow in which there are a label with a pixmap inside it, and near it a vertical bar that
should allow to zoom the image.
What should I do to scale my image when I 'move' (sorry, I don't know the correct word to explain it) the vertical bar?
If you could paste some code maybe it would be easier to understand.
Thank you
If you set its fixed size, yes.-
Why would you scale the pixmap?
I thought you wanted the pixmap to be fully displayed.
If you only want part of the image to be visible, then yes, scale the image, take the part you want to be visible, and let the label show it.
Cheers,
_
Maybe it's better to simplify the question.
I have an image (a pixmap in a label) and near it, a vertical bar. All of this is in a mainwindow.
Can you tell me how can I do to zoom a little my image using the vertical bar?
I don't want only a part of the image visibile, so (I suppose) I have to scale the image, but I don't know
how to do it because everytime I do it the label (that is fixed) doesn't allow the image inside it to scale.
So the image either remains of the same size (not scaling) or shows only a part of itself.
I want to show it entirely, not fully displayed but only a little larger.
If the image is to be shown entirely, the label needs to have a size big enough to show the whole image.
In which case the easiest way is to resize the label appropriately and let it scale the pixmap.
See comment #4
Cheers,
_
Ok, so:
1) if I fix a size big enough to contain the image larger, if the image is not zoomed in that moment there will be empty spaces between the label and the image?
2)how can I connect this operation (scaling of the image) with the changes of the vertical bar?
Thank you
Because you wrote "If the image is to be shown entirely, the label needs to have a size big enough to show the whole image."
I have to zoom it showing it entirely.
Can you show me some code to understand how to do the second point (vertical bar)?
I think we have a communication problem here. You are using the word "zoom". For us, to "zoom" an image means that you scale the image to make it larger ("zoom in") or smaller ("zoom out") than the rectangle it is displayed in.
In most image display applications, the window stays the same size, so when you "zoom in" only part of the image is displayed, and usually scrollbars are shown so you can move to different parts of the image. When you "zoom out", more of the image is visible and as you zoom out more, the image becomes smaller than the window in which it is displayed and the scrollbars are removed. Zooming scales the image while the window size does not change.
If you resize the window (by dragging the window to make it larger or smaller) the zoom level does not change, but more or less of the image is shown. Resizing the window does not scale the image.
So, please explain exactly what you want to happen when you move your vertical bar:
1) Do you want the window that the image is displayed in to get larger? (Resize the window, image stays the same size)
2) Do you want the image to get larger or smaller? (Zoom the image, window stays the same size)
3) Do you want both the window and the image to change size? (Zoom the image and at the same time make the window larger or smaller so the whole image is visible)
Thank you d_stranz, maybe we have been a misunderstanding as you said.
By the way, I partly solved the last problem so now I have a label with a fixed size and
when I zoom in the image it becomes partially visible.
How can I use the horizontal and vertical scrollbars in order to show the image completely?
I have written the code "connect...ecc...." and the relative signals and slots but I cannot find
a code for the function to connect to the scrollbars.
Bookmarks