Image Component Library (ICL)
|
Utility class to avoid Qt warning when accesing QLabels from differnt Threads. More...
#include <CompabilityLabel.h>
Public Member Functions | |
CompabilityLabel (const QString &text, QWidget *parent=0) | |
Create a new label with given text and given parent widget. | |
virtual void | paintEvent (QPaintEvent *evt) |
reimplemented drawin function (draw the current text centered) | |
void | setNum (int i) |
make the label show an integer value | |
void | setNum (float f) |
make the label show a float value | |
void | setText (const QString &text) |
make the lable show a given string | |
QString | text () const |
returns the current text (also thread save) | |
Qt::Alignment | getAlignment () const |
returns current alignment | |
void | setAlignment (Qt::Alignment a) |
sets new text alignment | |
Private Attributes | |
QString | m_sText |
current text (protected by the mutex) | |
Qt::Alignment | m_alignment |
text alignment | |
QMutex | m_oMutex |
Thread-safety mutex. |
Utility class to avoid Qt warning when accesing QLabels from differnt Threads.
QLabels can not be used from different Threads. So if a QLabel is created in in the main thread, it might not be set up to show another text/number from the working thread. As a workaround, the "label" component of the ICL GUI API uses not the original QLabel but this thread-save reimplementation called CompabilityLabel.
icl::qt::CompabilityLabel::CompabilityLabel | ( | const QString & | text, |
QWidget * | parent = 0 |
||
) |
Create a new label with given text and given parent widget.
Qt::Alignment icl::qt::CompabilityLabel::getAlignment | ( | ) | const |
returns current alignment
virtual void icl::qt::CompabilityLabel::paintEvent | ( | QPaintEvent * | evt | ) | [virtual] |
reimplemented drawin function (draw the current text centered)
void icl::qt::CompabilityLabel::setAlignment | ( | Qt::Alignment | a | ) |
sets new text alignment
void icl::qt::CompabilityLabel::setNum | ( | int | i | ) |
make the label show an integer value
void icl::qt::CompabilityLabel::setNum | ( | float | f | ) |
make the label show a float value
void icl::qt::CompabilityLabel::setText | ( | const QString & | text | ) |
make the lable show a given string
QString icl::qt::CompabilityLabel::text | ( | ) | const |
returns the current text (also thread save)
Qt::Alignment icl::qt::CompabilityLabel::m_alignment [private] |
text alignment
QMutex icl::qt::CompabilityLabel::m_oMutex [mutable, private] |
Thread-safety mutex.
QString icl::qt::CompabilityLabel::m_sText [private] |
current text (protected by the mutex)