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. Custom Event Compression
Forum Updated to NodeBB v4.3 + New Features

Custom Event Compression

Scheduled Pinned Locked Moved General and Desktop
6 Posts 2 Posters 6.0k 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.
  • S Offline
    S Offline
    steno
    wrote on last edited by
    #1

    I don't see a way to compress custom event types. Does anyone have a solution or know of a work around for this problem?

    1 Reply Last reply
    0
    • L Offline
      L Offline
      loladiro
      wrote on last edited by
      #2

      You have to subclass Q(Core)Application (depending on whether you want gui or not) and then overwrite the compressEvent function. And don't forget to call the parent function at the end so that the standard events are compressed (a little plagarism from QApplication):

      @
      bool MyApplication::compressEvent(QEvent *event, QObject *receiver, QPostEventList *postedEvents)
      {
      if(event->type()==MyEventType)
      {
      for (int i = 0; i < postedEvents->size(); ++i) {
      const QPostEvent &cur = postedEvents->at(i);
      if (cur.receiver != receiver || cur.event == 0 || cur.event->type() != event->type())
      continue;
      delete event;
      return true;
      }
      return false;
      }
      return QCoreApplication::compressEvent(event, receiver, postedEvents);
      }
      @

      1 Reply Last reply
      0
      • S Offline
        S Offline
        steno
        wrote on last edited by
        #3

        Yea, that would work. I didn't see compressEvent in the docs let alone that its a virtual function.

        1 Reply Last reply
        0
        • S Offline
          S Offline
          steno
          wrote on last edited by SGaist
          #4

          Created a bug since this isn't documented."Bug Report":https://bugreports.qt.io/browse/QTBUG-19711

          1 Reply Last reply
          0
          • S Offline
            S Offline
            steno
            wrote on last edited by
            #5

            Ok after further investigation the above code snippet wont work sort of. You would have to include qthread_p.h to get the definition of QPostEventList and QPostEvent. IMO including private files should be avoided at all costs.

            1 Reply Last reply
            0
            • L Offline
              L Offline
              loladiro
              wrote on last edited by
              #6

              Well, I personally don't see another solution then, but you might find one. Good luck!

              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