Results 1 to 3 of 3

Thread: Nested classes and problem with meta-object system

  1. #1
    Join Date
    Jun 2011
    Location
    Porto Alegre, Brazil
    Posts
    482
    Thanks
    165
    Thanked 2 Times in 2 Posts
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default Nested classes and problem with meta-object system

    Hello!

    I want to create a class and nest it inside the unique other class that will be using it. This nested class is a QObject derived one, being a reimplementation of QVariantAnimation.

    The problem is that when I put it inside my base class, the compiler states "error 1" after the message "Error: Meta object features not supported for nested classes".

    Qt Code:
    1. class MessageFrame : public QFrame
    2. {
    3. Q_OBJECT
    4. Q_PROPERTY(QString currentText READ currentText WRITE setCurrentText)
    5. Q_ENUMS(Icon)
    6. Q_ENUMS(TextType)
    7.  
    8. class MessageFrameAnimator : public QVariantAnimation
    9. {
    10. Q_OBJECT
    11. public:
    12. MessageFrameAnimator(QObject* parent = 0) :
    13. QVariantAnimation(parent)
    14. {}
    15.  
    16. virtual ~MessageFrameAnimator() {}
    17.  
    18. protected:
    19. void updateCurrentValue(const QVariant & value) //Does nothing
    20. {
    21. Q_UNUSED(value);
    22. }
    23. };
    24.  
    25. public:
    26. //...
    To copy to clipboard, switch view to plain text mode 

    It's not imperative to use this class as a nested one, but I'm still curious how to solve this problem - if there is any solution to it. Does somebody knows how to nest my class correctly?

    Thanks,

    Momergil
    May the Lord be with you. Always.

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Nested classes and problem with meta-object system

    That's a limitation of the current implementation of MOC.

    I think you can forward declare the nested class and put its declaration into its own header.

    Cheers,
    _

  3. The following user says thank you to anda_skoa for this useful post:

    Momergil (18th June 2014)

  4. #3
    Join Date
    Jun 2011
    Location
    Porto Alegre, Brazil
    Posts
    482
    Thanks
    165
    Thanked 2 Times in 2 Posts
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Nested classes and problem with meta-object system

    Quote Originally Posted by anda_skoa View Post
    That's a limitation of the current implementation of MOC.
    Hmm, I hope this will be fixed in the future...

    Quote Originally Posted by anda_skoa View Post
    I think you can forward declare the nested class and put its declaration into its own header.

    Cheers,
    _
    Well, in that case the organization I wanted with this action will be missed anyway :/

    Thanks for the reply,

    Momergil
    May the Lord be with you. Always.

Similar Threads

  1. How to access a nested QML object from C++?
    By TheIndependentAquarius in forum Qt Quick
    Replies: 3
    Last Post: 1st January 2014, 19:12
  2. Meta object features not supported for nested classes
    By ustulation in forum Qt Programming
    Replies: 1
    Last Post: 15th September 2012, 16:36
  3. Static Meta Object
    By sajis997 in forum Qt Programming
    Replies: 1
    Last Post: 30th January 2012, 10:18
  4. About template meta-programming problem with QT
    By gaserland in forum Qt Programming
    Replies: 1
    Last Post: 28th February 2011, 07:40
  5. Meta-Object Compiler Design Details
    By lexfridman in forum Qt Programming
    Replies: 2
    Last Post: 9th February 2011, 00:53

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.