Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
QLabel not showing image correctly
I have written an application, that links statically to the plug-in, that is of my own code. Everything is done in Qt. My plug-in has KDevice class, which has *QWidget face() function. The widget this function returns has QLabel on it with an image. The image is taken from resource inside plug-in. This face gets added to some layout of the app on start-up after loading the plug-in.
The problem here is that the image in QLabel gets resized to whatever size Qt wants. Especially if my file is portrait of landscape type, not a rectangle. My goal is to make Qt keep the size of the image.
Jeroentjehome last edited by
There are hasWidthForHeight and hasHeightForWidth functions for QLabel. When you do need to set the constraints, subclass the QLabel and redefine those functions to keep the aspect ratio
Thanks, but maybe I should use another widget?
Ha! I got it, my fault. I was setting QLabel's image like that:
instead of correct
May this post be helpful to someone else :)