Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. [SOLVED] What to do with an event for a QLabel after I've intercepted it?
Forum Updated to NodeBB v4.3 + New Features

[SOLVED] What to do with an event for a QLabel after I've intercepted it?

Scheduled Pinned Locked Moved General and Desktop
2 Posts 2 Posters 789 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    Moschops
    wrote on last edited by
    #1

    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;
    elideBaselineDirText(text);
    ui->baselineCurrentDir->setText(text);
    }
    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?

    1 Reply Last reply
    0
    • sierdzioS Offline
      sierdzioS Offline
      sierdzio
      Moderators
      wrote on last edited by
      #2

      Yes, that should work.

      (Z(:^

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved