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. Qobject_cast and Q_DECLARE_INTERFACE
Forum Updated to NodeBB v4.3 + New Features

Qobject_cast and Q_DECLARE_INTERFACE

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 2.9k 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.
  • P Offline
    P Offline
    p-himik
    wrote on last edited by
    #1

    Nearby topic made me think that I don't understand something. qobject_cast documentation says that returned value it undefined if template argument doesn't inherit QObject. But interfaces don't inherit it though Plug & Paint example uses qobject_cast from QObject* to an interface.
    Is this an error in the documentation or did I miss something?

    1 Reply Last reply
    0
    • A Offline
      A Offline
      adam.bogocz
      wrote on last edited by
      #2

      Hi,
      that is reason why you use Q_INTERFACES macro, it tells to metaObject that it is "qobject & your inteface" during qobject_cast.. without that macro, you will get null pointer from that cast .. it is in the doc

      1 Reply Last reply
      0
      • P Offline
        P Offline
        p-himik
        wrote on last edited by
        #3

        Yes, now I found the line which describes it. Multiple "Warning"s about Q_OBJECT confused me.

        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