Resize photoview to the size of embedded image

This commit is contained in:
hunbernd 2020-01-21 21:23:42 +01:00
parent 69a2933590
commit 83b18509e2
3 changed files with 7 additions and 10 deletions

View File

@ -62,6 +62,7 @@ void PhotoView::setPixmap(const QPixmap& pixmap)
else{
ui->photoLabel->setPixmap(pixmap);
}
this->adjustSize();
}
void PhotoView::setTitle(const QString& text)

View File

@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>565</width>
<height>464</height>
<width>346</width>
<height>107</height>
</rect>
</property>
<property name="windowTitle">
@ -38,7 +38,7 @@
<item row="1" column="0" colspan="2">
<widget class="QFrame" name="frame">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
@ -55,9 +55,6 @@
<property name="text">
<string/>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
</layout>
@ -142,7 +139,7 @@
</property>
<property name="sizeHint" stdset="0">
<size>
<width>398</width>
<width>0</width>
<height>20</height>
</size>
</property>

View File

@ -31,7 +31,7 @@ AspectRatioPixmapLabel::AspectRatioPixmapLabel(QWidget *parent) :
void AspectRatioPixmapLabel::setPixmap ( const QPixmap & p)
{
pix = p;
QLabel::setPixmap(scaledPixmap());
QLabel::setPixmap(pix);
}
int AspectRatioPixmapLabel::heightForWidth( int width ) const
@ -41,8 +41,7 @@ int AspectRatioPixmapLabel::heightForWidth( int width ) const
QSize AspectRatioPixmapLabel::sizeHint() const
{
int w = this->width();
return QSize( w, heightForWidth(w) );
return QSize(pix.width(), pix.height());
}
QPixmap AspectRatioPixmapLabel::scaledPixmap() const