Can someone point me in the right direction of making a click-able label? I'm working with some code I found on a site, but I'm not converting it right from key event to most events...
{
Q_OBJECT
protected:
};
{
if (event
->type
() == QEvent::MouseButtonPress) { QMouseEvent *MouseEvent
= static_cast<QMouseEvent
*>
(event
);
qDebug("MouseClicked", MouseEvent->clicked());
return true;
} else {
// standard event processing
return QObject::eventFilter(obj, event
);
}
}
class ClickLabel : public QObject
{
Q_OBJECT
protected:
bool eventFilter(QObject *obj, QEvent *event);
};
bool ClickLabel::eventFilter(QObject *obj, QEvent *event)
{
if (event->type() == QEvent::MouseButtonPress) {
QMouseEvent *MouseEvent = static_cast<QMouseEvent *>(event);
qDebug("MouseClicked", MouseEvent->clicked());
return true;
} else {
// standard event processing
return QObject::eventFilter(obj, event);
}
}
To copy to clipboard, switch view to plain text mode
errors
error: invalid static_cast from type 'QEvent*' to type 'QMouseEvent*'
error: invalid use of incomplete type 'struct QMouseEvent'
error: forward declaration of 'struct QMouseEvent'
Bookmarks