Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
[SOLVED] What to do with an event for a QLabel after I've intercepted it?
Moschops last edited by
I have a QLabel, and I wanted the text to elide as it was resized. I added an event filter (for that QLabel only) and when the event is a resize event, I fiddle with the text. Like this:
bool GeneralView::eventFilter(QObject* target, QEvent* event)
if (event->type() == QEvent::Resize)
QString text = unelidedBaselineDirText;
return target->eventFilter(target, event);
At the moment, every event then gets passed to the QLabel's own eventFilter functions (at the end there); my thinking is that whatever would have happened with this QLabel's event handling will now still happen, because I am catching the event, doing something, and then passing the event onwards to where it was going anyway. This makes sense inside my head, but it's worth checking; is this the right thing to do here?
Yes, that should work.