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. does parentClass's Q_OBJECT work for nestedClass?
Forum Updated to NodeBB v4.3 + New Features

does parentClass's Q_OBJECT work for nestedClass?

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 2 Posters 330 Views
  • 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.
  • O Offline
    O Offline
    opengpu
    wrote on last edited by VRonin
    #1

    does parentClass's Q_OBJECT work for nestedClass?
    i found this is illegal:

    class P : publica QWidget
    {
        Q_OBJECT
    protected:
        class N : public QWidget
        {
            Q_OBJECT
        }
    }
    

    so can i write like this?

    class P : publica QWidget
    {
        Q_OBJECT
    protected:
        class N : public QWidget
        {
            //Q_OBJECT
        }
    }
    
    1 Reply Last reply
    1
    • VRoninV Offline
      VRoninV Offline
      VRonin
      wrote on last edited by VRonin
      #2

      @opengpu said in does parentClass's Q_OBJECT work for nestedClass?:

      so can i write like this?

      Yes (as long as you don't declare signal/slots/properties/invokables in the inner class). Whether you should is another topic.

      i found this is illegal:

      It's not illegal per-se it's just that moc is not smart enough to handle it. It is valid if you skip moc using, for example, Verdigris

      "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
      ~Napoleon Bonaparte

      On a crusade to banish setIndexWidget() from the holy land of Qt

      1 Reply Last reply
      6

      • Login

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