所以我有一个QDialog及其在垂直布局中的设置。 我正在添加各种线路输入和标签。 在顶部,我有一个特定的QLabel加载QPixmap并显示图像。 现在,即使当我使用scaledContents(true) ,图像scaledContents(true)膨胀到原来的大小。
我无法设置几何细节,因为它们在QtCreator中被禁用,因为我处于Verical布局中,所以所有内容都会自动缩放。
我使用QDialog的构造函数中的setFixedSize() ,但这并没有在QtCreator中给我正确的预览。
如何在QtCreator中设置内部布局的固定大小?
So I have a QDialog and its set in Vertical layout. I am adding various line inputs and labels. On top I have one particular QLabel that loads QPixmap and displays image. Now even when I use scaledContents(true) the image tends to bloat up into its original size.
I cannot set geometry details as they are disabled in QtCreator for I am inside a Verical layout, so everything is scaled automatically.
I resorted to using setFixedSize() from QDialog's constructor, but this doesnt give me correct preview in QtCreator.
How to set a fixed size inside layout in QtCreator?
最满意答案
您需要为QLabel的QPixmap对象选择Qt::KeepAspectRatio
例如:
QPixmap px; QLabel label; label->setPixmap(px.scaled(label->width(), label->height(),Qt::KeepAspectRatio));You need to select Qt::KeepAspectRatio for the QPixmap object within QLabel
For example:
QPixmap px; QLabel label; label->setPixmap(px.scaled(label->width(), label->height(),Qt::KeepAspectRatio));更多推荐
发布评论