A label which is able to show elided and rotated plain text. More...
#include <qxtlabel.h>

Public Slots | |
| void | setText (const QString &text) |
Signals | |
| void | clicked () |
| void | textChanged (const QString &text) |
Public Member Functions | |
| QxtLabel (QWidget *parent=0, Qt::WindowFlags flags=0) | |
| QxtLabel (const QString &text, QWidget *parent=0, Qt::WindowFlags flags=0) | |
| virtual | ~QxtLabel () |
| QString | text () const |
| Qt::Alignment | alignment () const |
| void | setAlignment (Qt::Alignment alignment) |
| Qt::TextElideMode | elideMode () const |
| void | setElideMode (Qt::TextElideMode mode) |
| Qxt::Rotation | rotation () const |
| void | setRotation (Qxt::Rotation rotation) |
| virtual QSize | sizeHint () const |
| virtual QSize | minimumSizeHint () const |
Protected Member Functions | |
| virtual void | changeEvent (QEvent *event) |
| virtual void | mousePressEvent (QMouseEvent *event) |
| virtual void | mouseReleaseEvent (QMouseEvent *event) |
| virtual void | paintEvent (QPaintEvent *event) |
Properties | |
| QString | text |
| This property holds the text of the label. | |
| Qt::Alignment | alignment |
| This property holds the alignment of the text. | |
| Qt::TextElideMode | elideMode |
| This property holds the elide mode of the text. | |
| Qxt::Rotation | rotation |
| This property holds the rotation of the label. | |
Friends | |
| class | QxtLabelPrivate |
A label which is able to show elided and rotated plain text.
QxtLabel is a label which is able to show elided and rotated plain text. In addition, QxtLabel provides a signal for clicking.
QxtLabel in action.
Definition at line 35 of file qxtlabel.h.
| QxtLabel::QxtLabel | ( | QWidget * | parent = 0, |
| Qt::WindowFlags | flags = 0 |
||
| ) | [explicit] |
Constructs a new QxtLabel with parent and flags.
Definition at line 92 of file qxtlabel.cpp.
References QXT_INIT_PRIVATE.
: QFrame(parent, flags)
{
QXT_INIT_PRIVATE(QxtLabel);
qxt_d().init();
}
| QxtLabel::QxtLabel | ( | const QString & | text, |
| QWidget * | parent = 0, |
||
| Qt::WindowFlags | flags = 0 |
||
| ) | [explicit] |
Constructs a new QxtLabel with text, parent and flags.
Definition at line 101 of file qxtlabel.cpp.
References QXT_INIT_PRIVATE.
: QFrame(parent, flags)
{
QXT_INIT_PRIVATE(QxtLabel);
qxt_d().init(text);
}
| QxtLabel::~QxtLabel | ( | ) | [virtual] |
| Qt::Alignment QxtLabel::alignment | ( | ) | const |
Referenced by setAlignment().
| void QxtLabel::changeEvent | ( | QEvent * | event ) | [protected, virtual] |
Definition at line 303 of file qxtlabel.cpp.
{
QFrame::changeEvent(event);
switch (event->type())
{
case QEvent::FontChange:
case QEvent::ApplicationFontChange:
qxt_d().updateLabel();
break;
default:
// nothing to do
break;
}
}
| QxtLabel::clicked | ( | ) | [signal] |
This signal is emitted whenever the label has been clicked.
Referenced by mouseReleaseEvent().
| Qt::TextElideMode QxtLabel::elideMode | ( | ) | const |
| QSize QxtLabel::minimumSizeHint | ( | ) | const [virtual] |
Definition at line 238 of file qxtlabel.cpp.
References sizeHint(), and Vertical_Mask.
{
switch (qxt_d().mode)
{
#if QT_VERSION >= 0x040200
case Qt::ElideNone:
return sizeHint();
#endif // QT_VERSION
default:
{
const QFontMetrics& fm = fontMetrics();
QSize size(fm.width("..."), fm.height());
if (qxt_d().rot & Vertical_Mask)
size.transpose();
return size;
}
}
}
| void QxtLabel::mousePressEvent | ( | QMouseEvent * | event ) | [protected, virtual] |
Definition at line 321 of file qxtlabel.cpp.
{
QFrame::mousePressEvent(event);
qxt_d().time.start();
}
| void QxtLabel::mouseReleaseEvent | ( | QMouseEvent * | event ) | [protected, virtual] |
Definition at line 330 of file qxtlabel.cpp.
References clicked().
{
QFrame::mouseReleaseEvent(event);
if (qxt_d().time.elapsed() < qApp->doubleClickInterval())
emit clicked();
}
| void QxtLabel::paintEvent | ( | QPaintEvent * | event ) | [protected, virtual] |
Definition at line 260 of file qxtlabel.cpp.
References Qxt::Clockwise, Qxt::CounterClockwise, text(), Qxt::UpsideDown, and Vertical_Mask.
{
QFrame::paintEvent(event);
QPainter p(this);
p.rotate(qxt_d().rot);
QRect r = contentsRect();
switch (qxt_d().rot)
{
case Qxt::UpsideDown:
p.translate(-r.width(), -r.height());
break;
case Qxt::Clockwise:
p.translate(0, -r.width());
break;
case Qxt::CounterClockwise:
p.translate(-r.height(), 0);
break;
default:
// nothing to do
break;
}
if (qxt_d().rot & Vertical_Mask)
{
QSize s = r.size();
s.transpose();
r = QRect(r.topLeft(), s);
}
#if QT_VERSION < 0x040200
const QString elidedText = QAbstractItemDelegate::elidedText(fontMetrics(), r.width(), qxt_d().mode, qxt_d().text);
#else // QT_VERSION >= 0x040200
const QString elidedText = fontMetrics().elidedText(qxt_d().text, qxt_d().mode, r.width());
#endif // QT_VERSION
p.drawText(r, qxt_d().align, elidedText);
}
| Qxt::Rotation QxtLabel::rotation | ( | ) | const |
Referenced by setRotation().
| void QxtLabel::setAlignment | ( | Qt::Alignment | alignment ) |
Definition at line 146 of file qxtlabel.cpp.
References alignment().
| void QxtLabel::setElideMode | ( | Qt::TextElideMode | mode ) |
Definition at line 169 of file qxtlabel.cpp.
{
if (qxt_d().mode != mode)
{
qxt_d().mode = mode;
qxt_d().updateLabel();
}
}
| void QxtLabel::setRotation | ( | Qxt::Rotation | rotation ) |
Definition at line 192 of file qxtlabel.cpp.
References Qxt::Clockwise, Qxt::CounterClockwise, Qxt::NoRotation, rotation(), Qxt::UpsideDown, and Vertical_Mask.
{
if (qxt_d().rot != rotation)
{
Qxt::Rotation prev = qxt_d().rot;
qxt_d().rot = rotation;
switch (rotation)
{
case Qxt::NoRotation:
case Qxt::UpsideDown:
if (prev & Vertical_Mask)
{
updateGeometry();
}
break;
case Qxt::Clockwise:
case Qxt::CounterClockwise:
if ((prev & Vertical_Mask) == 0)
{
updateGeometry();
}
break;
default:
// nothing to do
break;
}
}
update();
}
| void QxtLabel::setText | ( | const QString & | text ) | [slot] |
Definition at line 122 of file qxtlabel.cpp.
References text(), and textChanged().
{
if (qxt_d().text != text)
{
qxt_d().text = text;
qxt_d().updateLabel();
emit textChanged(text);
}
}
| QSize QxtLabel::sizeHint | ( | ) | const [virtual] |
Definition at line 226 of file qxtlabel.cpp.
References text(), and Vertical_Mask.
Referenced by minimumSizeHint().
{
const QFontMetrics& fm = fontMetrics();
QSize size(fm.width(qxt_d().text), fm.height());
if (qxt_d().rot & Vertical_Mask)
size.transpose();
return size;
}
| QString QxtLabel::text | ( | ) | const |
Referenced by paintEvent(), setText(), and sizeHint().
| void QxtLabel::textChanged | ( | const QString & | text ) | [signal] |
Referenced by setText().
friend class QxtLabelPrivate [friend] |
Definition at line 38 of file qxtlabel.h.
Qt::Alignment QxtLabel::alignment [read, write] |
This property holds the alignment of the text.
The text is aligned according to this property. The default value is Qt::AlignCenter.
Definition at line 40 of file qxtlabel.h.
Qt::TextElideMode QxtLabel::elideMode [read, write] |
This property holds the elide mode of the text.
The text is elided according to this property. The default value is Qt::ElideMiddle.
Definition at line 41 of file qxtlabel.h.
Qxt::Rotation QxtLabel::rotation [read, write] |
This property holds the rotation of the label.
The label is rotated according to this property. The default value is Qxt::NoRotation.
Definition at line 42 of file qxtlabel.h.
QString QxtLabel::text [read, write] |
This property holds the text of the label.
Definition at line 38 of file qxtlabel.h.
1.7.2