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. Use QEvent::MetaCall for our own QEvent-derived class
Forum Updated to NodeBB v4.3 + New Features

Use QEvent::MetaCall for our own QEvent-derived class

Scheduled Pinned Locked Moved General and Desktop
1 Posts 1 Posters 630 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.
  • J Offline
    J Offline
    Jakob
    wrote on last edited by
    #1

    We have an application where we mix Qt(5) with some other technologies. In particular, the handling of threads is done through Boost::asio. One of the things that happens often is that we want to post some jobs on a worker thread, but want to make sure that either some signal handler, or some callback is executed on the main thread again. However, not in all scenarios is there some QObject available to execute the callback on (in particular, in some rare scenarios the callback could be a global)

    We have been thinking to create a small wrapper (involving some template magic) that will internally call QApplication::postEvent(QApplication::instance(), OurCallBackEvent()). The details I omitted (because I have no idea what they will look like), but the basic idea is to create our own QEvent class OurCallBackEvent, which will use the QEvent::MetaCall type.

    Does that make sense? My worry in particular is that it may be not a good idea to use the predefined QEvent::MetaCall type. What could go wrong, if anything?

    Btw: we also looked at QMetaObject::invokeMethod, but that doesn't seem to have overloads for function pointer syntax (which we really, really like) and, btw, which also only works when we have a QObject available to target.

    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