The widget doesn't have its final size at construction time, so the
width for eliding is not yet known. Let ElidedLabel do the job.
This commit is contained in:
J-P Nurmi 2018-11-15 10:23:07 +01:00
Родитель b546e7c224
Коммит fae1c0dbdd
2 изменённых файлов: 11 добавлений и 6 удалений

Просмотреть файл

@ -371,10 +371,8 @@ ShareUserLine::ShareUserLine(QSharedPointer<Share> share,
{
_ui->setupUi(this);
QString sharedWithText(share->getShareWith()->format());
QFontMetrics metrics(_ui->sharedWith->font());
QString elidedText = metrics.elidedText(sharedWithText, Qt::ElideRight, _ui->sharedWith->width());
_ui->sharedWith->setText(elidedText);
_ui->sharedWith->setElideMode(Qt::ElideRight);
_ui->sharedWith->setText(share->getShareWith()->format());
// adds permissions
// can edit permission

Просмотреть файл

@ -97,9 +97,9 @@
</widget>
</item>
<item>
<widget class="QLabel" name="sharedWith">
<widget class="OCC::ElidedLabel" name="sharedWith">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Maximum">
<sizepolicy hsizetype="Ignored" vsizetype="Maximum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
@ -204,6 +204,13 @@
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>OCC::ElidedLabel</class>
<extends>QLabel</extends>
<header>elidedlabel.h</header>
</customwidget>
</customwidgets>
<resources>
<include location="../../client.qrc"/>
</resources>