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. const qobject_cast for interfaces
Forum Updated to NodeBB v4.3 + New Features

const qobject_cast for interfaces

Scheduled Pinned Locked Moved General and Desktop
qdeclareinterfaqobjectcast
1 Posts 1 Posters 735 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.
  • A Offline
    A Offline
    Asperamanca
    wrote on 24 Jul 2015, 13:16 last edited by Asperamanca
    #1

    I like to use Q_DECLARE_INTERFACE, because it allows me to use qobject_cast for these interfaces (provided the implementation has the Q_INTERFACES makro)

    All works well, until I try to cast a const instance.

    So this works:
    ISomeInterface* pInterface = qobject_cast<ISomeInterface*>(pSomeObject);

    And this doesn't:
    const ISomeInterface* pInterface = qobject_cast<const ISomeInterface*>(pSomeObject);

    Error message is:
    'const class ISomeInterface' has no member named 'qt_check_for_QOBJECT_macro'
    'const class ISomeInterface' has no member named 'qt_check_for_QOBJECT_macro'

    Any ideas?

    1 Reply Last reply
    0

    1/1

    24 Jul 2015, 13:16

    • Login

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