27 #include "../WGuiConsts.h"
29 #include "WScaleLabel.h"
33 m_additionalWidth( 0 ),
40 QLabel( text, parent ),
42 m_additionalWidth( 0 ),
50 m_additionalWidth( 0 ),
51 m_minLength( WPREFERRED_LABEL_LENGTH )
57 QLabel( text, parent ),
59 m_additionalWidth( 0 ),
60 m_minLength( WPREFERRED_LABEL_LENGTH )
68 setSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::Maximum );
69 setMargin( WGLOBAL_MARGIN );
70 setTextInteractionFlags( Qt::TextSelectableByMouse );
102 QString useText = fontMetrics().elidedText(
m_orgText, Qt::ElideRight, width() );
103 QLabel::setText( useText );
virtual size_t calculateSize(size_t chars) const
Calculate the size that is needed for the given number of chars.
void fitTextToSize()
set the actual text which is shown on the QLabel
virtual void setMinimalLength(size_t chars)
How many characters should be visible all the time?
void construct()
Deferred construction.
virtual QSize sizeHint() const
overwritten from QLabel, returning the widgets prefered size
size_t m_minLength
Minimal character number.
int m_additionalWidth
The additional width we need to reserver (like for margins).
virtual QSize minimumSizeHint() const
overwritten from QLabel, returning the widgets prefered size
virtual size_t getMinimalLength() const
Get the current minimal number of characters.
virtual void resizeEvent(QResizeEvent *event)
custom implementation of the resize event to fit the QString into the labels current size
WScaleLabel(size_t length=WPREFERRED_LABEL_LENGTH, QWidget *parent=NULL)
Constructor.
virtual void addAdditionalWidth(int margin)
Set this to reserve extra space for a margin.
virtual void setText(const QString &text)
reimplemented function to setText
QString m_orgText
QString to remember the original unshortend text of the widget.