![]() |
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. More... | |
| virtual void | paintEvent (QPaintEvent *evt) |
| reimplemented drawin function (draw the current text centered) More... | |
| void | setNum (int i) |
| make the label show an integer value More... | |
| void | setNum (float f) |
| make the label show a float value More... | |
| void | setText (const QString &text) |
| make the lable show a given string More... | |
| QString | text () const |
| returns the current text (also thread save) More... | |
| Qt::Alignment | getAlignment () const |
| returns current alignment More... | |
| void | setAlignment (Qt::Alignment a) |
| sets new text alignment More... | |
Public Member Functions inherited from icl::qt::ThreadedUpdatableWidget | |
| ThreadedUpdatableWidget (QWidget *parent=0) | |
| Base constructor. More... | |
| void | updateFromOtherThread () |
| call this function to update a widget's UI from an external thread More... | |
| virtual bool | event (QEvent *event) |
| automatically called by Qt's event processing mechanism More... | |
Private Attributes | |
| QString | m_sText |
| current text (protected by the mutex) More... | |
| Qt::Alignment | m_alignment |
| text alignment More... | |
| QMutex | m_oMutex |
| Thread-safety mutex. More... | |
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 |
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)
|
private |
text alignment
|
mutableprivate |
Thread-safety mutex.
|
private |
current text (protected by the mutex)
1.8.15