Image Component Library (ICL)
Public Member Functions | Private Attributes | List of all members
icl::qt::CompabilityLabel Class Reference

Utility class to avoid Qt warning when accesing QLabels from differnt Threads. More...

#include <CompabilityLabel.h>

Inheritance diagram for icl::qt::CompabilityLabel:
icl::qt::ThreadedUpdatableWidget

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...
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ CompabilityLabel()

icl::qt::CompabilityLabel::CompabilityLabel ( const QString &  text,
QWidget *  parent = 0 
)

Create a new label with given text and given parent widget.

Member Function Documentation

◆ getAlignment()

Qt::Alignment icl::qt::CompabilityLabel::getAlignment ( ) const

returns current alignment

◆ paintEvent()

virtual void icl::qt::CompabilityLabel::paintEvent ( QPaintEvent *  evt)
virtual

reimplemented drawin function (draw the current text centered)

◆ setAlignment()

void icl::qt::CompabilityLabel::setAlignment ( Qt::Alignment  a)

sets new text alignment

◆ setNum() [1/2]

void icl::qt::CompabilityLabel::setNum ( int  i)

make the label show an integer value

◆ setNum() [2/2]

void icl::qt::CompabilityLabel::setNum ( float  f)

make the label show a float value

◆ setText()

void icl::qt::CompabilityLabel::setText ( const QString &  text)

make the lable show a given string

◆ text()

QString icl::qt::CompabilityLabel::text ( ) const

returns the current text (also thread save)

Member Data Documentation

◆ m_alignment

Qt::Alignment icl::qt::CompabilityLabel::m_alignment
private

text alignment

◆ m_oMutex

QMutex icl::qt::CompabilityLabel::m_oMutex
mutableprivate

Thread-safety mutex.

◆ m_sText

QString icl::qt::CompabilityLabel::m_sText
private

current text (protected by the mutex)


The documentation for this class was generated from the following file: