Medical Imaging Interaction Toolkit  2016.11.0
Medical Imaging Interaction Toolkit
QClickableLabel Class Reference

A QLabel with multiple hotspots, that can be clicked. More...

#include <qclickablelabel.h>

Inheritance diagram for QClickableLabel:
Collaboration diagram for QClickableLabel:

Signals

void mousePressed (const QString &hotspotName)
 
void mousePressed (unsigned int hotspotIndex)
 
void mouseReleased (const QString &hotspotName)
 
void mouseReleased (unsigned int hotspotIndex)
 

Public Member Functions

 QClickableLabel (QWidget *parent, Qt::WindowFlags f=nullptr)
 
 QClickableLabel (const QString &text, QWidget *parent, Qt::WindowFlags f=nullptr)
 
virtual ~QClickableLabel ()
 
void AddHotspot (const QString &name, const QRect position)
 
void RemoveHotspot (const QString &name)
 
void RemoveHotspot (unsigned int hotspotIndex)
 
void RemoveAllHotspots ()
 

Protected Types

typedef std::vector< QRect > RectVectorType
 
typedef std::map< QString, unsigned int > NameToIndexMapType
 
typedef std::map< unsigned int, QString > IndexToNameMapType
 

Protected Member Functions

virtual void mousePressEvent (QMouseEvent *e) override
 
virtual void mouseReleaseEvent (QMouseEvent *e) override
 
unsigned int matchingRect (const QPoint &p)
 returns index == m_Hotspots.size() if nothing is hit More...
 

Protected Attributes

RectVectorType m_Hotspots
 
NameToIndexMapType m_HotspotIndexForName
 
IndexToNameMapType m_HotspotNameForIndex
 

Detailed Description

A QLabel with multiple hotspots, that can be clicked.

Specially useful in connection with a pixmap. Stretched images should be avoided, because the hotspots will not be adjusted in any way.

Definition at line 34 of file qclickablelabel.h.

Member Typedef Documentation

typedef std::map<unsigned int, QString> QClickableLabel::IndexToNameMapType
protected

Definition at line 67 of file qclickablelabel.h.

typedef std::map<QString, unsigned int> QClickableLabel::NameToIndexMapType
protected

Definition at line 66 of file qclickablelabel.h.

typedef std::vector<QRect> QClickableLabel::RectVectorType
protected

Definition at line 63 of file qclickablelabel.h.

Constructor & Destructor Documentation

QClickableLabel::QClickableLabel ( QWidget *  parent,
Qt::WindowFlags  f = nullptr 
)

Definition at line 23 of file qclickablelabel.cpp.

QClickableLabel::QClickableLabel ( const QString &  text,
QWidget *  parent,
Qt::WindowFlags  f = nullptr 
)

Definition at line 27 of file qclickablelabel.cpp.

QClickableLabel::~QClickableLabel ( )
virtual

Definition at line 31 of file qclickablelabel.cpp.

Member Function Documentation

void QClickableLabel::AddHotspot ( const QString &  name,
const QRect  position 
)
unsigned int QClickableLabel::matchingRect ( const QPoint &  p)
protected

returns index == m_Hotspots.size() if nothing is hit

Definition at line 90 of file qclickablelabel.cpp.

References m_Hotspots.

Referenced by mousePressEvent(), and mouseReleaseEvent().

void QClickableLabel::mousePressed ( const QString &  hotspotName)
signal

Referenced by mouseReleaseEvent().

void QClickableLabel::mousePressed ( unsigned int  hotspotIndex)
signal
void QClickableLabel::mousePressEvent ( QMouseEvent *  e)
overrideprotectedvirtual

Definition at line 70 of file qclickablelabel.cpp.

References m_HotspotNameForIndex, m_Hotspots, matchingRect(), and mouseReleased().

void QClickableLabel::mouseReleased ( const QString &  hotspotName)
signal

Referenced by mousePressEvent().

void QClickableLabel::mouseReleased ( unsigned int  hotspotIndex)
signal
void QClickableLabel::mouseReleaseEvent ( QMouseEvent *  e)
overrideprotectedvirtual

Definition at line 80 of file qclickablelabel.cpp.

References m_HotspotNameForIndex, m_Hotspots, matchingRect(), and mousePressed().

void QClickableLabel::RemoveAllHotspots ( )

Definition at line 63 of file qclickablelabel.cpp.

References m_HotspotIndexForName, m_HotspotNameForIndex, and m_Hotspots.

void QClickableLabel::RemoveHotspot ( const QString &  name)

Definition at line 42 of file qclickablelabel.cpp.

References m_HotspotIndexForName.

void QClickableLabel::RemoveHotspot ( unsigned int  hotspotIndex)

Definition at line 52 of file qclickablelabel.cpp.

References m_HotspotIndexForName, m_HotspotNameForIndex, and m_Hotspots.

Member Data Documentation

NameToIndexMapType QClickableLabel::m_HotspotIndexForName
protected

Definition at line 68 of file qclickablelabel.h.

Referenced by AddHotspot(), RemoveAllHotspots(), and RemoveHotspot().

IndexToNameMapType QClickableLabel::m_HotspotNameForIndex
protected
RectVectorType QClickableLabel::m_Hotspots
protected

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