Medical Imaging Interaction Toolkit  2026.06.00
Medical Imaging Interaction Toolkit
QClickableLabel Class Reference

A QLabel with named rectangular hotspots that emit signals when clicked. More...

#include <qclickablelabel.h>

Inheritance diagram for QClickableLabel:
Collaboration diagram for QClickableLabel:

Signals

void mousePressed (const QString &hotspotName)
 Emitted on mouse press within a hotspot (by name). More...
 
void mousePressed (unsigned int hotspotIndex)
 Emitted on mouse press within a hotspot (by index). More...
 
void mouseReleased (const QString &hotspotName)
 Emitted on mouse release within a hotspot (by name). More...
 
void mouseReleased (unsigned int hotspotIndex)
 Emitted on mouse release within a hotspot (by index). More...
 

Public Member Functions

 QClickableLabel (QWidget *parent, Qt::WindowFlags f={})
 Construct a clickable label. More...
 
 QClickableLabel (const QString &text, QWidget *parent, Qt::WindowFlags f={})
 Construct a clickable label with initial text. More...
 
 ~QClickableLabel () override
 Destructor. More...
 
void AddHotspot (const QString &name, const QRect position)
 Add a named hotspot at the given rectangle position. More...
 
void RemoveHotspot (const QString &name)
 Remove a hotspot by name. More...
 
void RemoveHotspot (unsigned int hotspotIndex)
 Remove a hotspot by index. More...
 
void RemoveAllHotspots ()
 Remove all hotspots. More...
 

Protected Types

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

Protected Member Functions

void mousePressEvent (QMouseEvent *e) override
 
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 named rectangular hotspots that emit signals when clicked.

Useful for overlaying interactive regions on a pixmap. Each hotspot is defined by a name and a QRect. When the user clicks within a hotspot, signals are emitted with both the hotspot name and index.

Note
Stretched images should be avoided because hotspot positions are not adjusted.
See also
QmitkStandardViews

Definition at line 35 of file qclickablelabel.h.

Member Typedef Documentation

◆ IndexToNameMapType

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

Definition at line 116 of file qclickablelabel.h.

◆ NameToIndexMapType

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

Definition at line 115 of file qclickablelabel.h.

◆ RectVectorType

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

Definition at line 112 of file qclickablelabel.h.

Constructor & Destructor Documentation

◆ QClickableLabel() [1/2]

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

Construct a clickable label.

Parameters
[in]parentThe parent widget.
[in]fWindow flags.

◆ QClickableLabel() [2/2]

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

Construct a clickable label with initial text.

Parameters
[in]textThe label text.
[in]parentThe parent widget.
[in]fWindow flags.

◆ ~QClickableLabel()

QClickableLabel::~QClickableLabel ( )
override

Destructor.

Member Function Documentation

◆ AddHotspot()

void QClickableLabel::AddHotspot ( const QString &  name,
const QRect  position 
)

Add a named hotspot at the given rectangle position.

Parameters
[in]nameThe hotspot name (used in signals).
[in]positionThe rectangular region of the hotspot.

◆ matchingRect()

unsigned int QClickableLabel::matchingRect ( const QPoint &  p)
protected

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

◆ mousePressed [1/2]

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

Emitted on mouse press within a hotspot (by name).

Parameters
[in]hotspotNameThe name of the pressed hotspot.

◆ mousePressed [2/2]

void QClickableLabel::mousePressed ( unsigned int  hotspotIndex)
signal

Emitted on mouse press within a hotspot (by index).

Parameters
[in]hotspotIndexThe index of the pressed hotspot.

◆ mousePressEvent()

void QClickableLabel::mousePressEvent ( QMouseEvent *  e)
overrideprotected

◆ mouseReleased [1/2]

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

Emitted on mouse release within a hotspot (by name).

Parameters
[in]hotspotNameThe name of the released hotspot.

◆ mouseReleased [2/2]

void QClickableLabel::mouseReleased ( unsigned int  hotspotIndex)
signal

Emitted on mouse release within a hotspot (by index).

Parameters
[in]hotspotIndexThe index of the released hotspot.

◆ mouseReleaseEvent()

void QClickableLabel::mouseReleaseEvent ( QMouseEvent *  e)
overrideprotected

◆ RemoveAllHotspots()

void QClickableLabel::RemoveAllHotspots ( )

Remove all hotspots.

◆ RemoveHotspot() [1/2]

void QClickableLabel::RemoveHotspot ( const QString &  name)

Remove a hotspot by name.

Parameters
[in]nameThe name of the hotspot to remove.

◆ RemoveHotspot() [2/2]

void QClickableLabel::RemoveHotspot ( unsigned int  hotspotIndex)

Remove a hotspot by index.

Parameters
[in]hotspotIndexThe index of the hotspot to remove.

Member Data Documentation

◆ m_HotspotIndexForName

NameToIndexMapType QClickableLabel::m_HotspotIndexForName
protected

Definition at line 117 of file qclickablelabel.h.

◆ m_HotspotNameForIndex

IndexToNameMapType QClickableLabel::m_HotspotNameForIndex
protected

Definition at line 118 of file qclickablelabel.h.

◆ m_Hotspots

RectVectorType QClickableLabel::m_Hotspots
protected

Definition at line 113 of file qclickablelabel.h.


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