Forums

OverviewFelgo 2 Support (Qt 5) › Error on adding an c++ enum

Tagged: ,

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #23496

    jrrobles79

    I created the next enum and added it to my project as any other c++ class, but Im having the next error, when I try to compile my app, only when I add the enum:

     

    /Users/jrobles/Felgo/Felgo/android_armv7/include/QtQml/qqmlprivate.h:106: error: only virtual member functions can be marked ‘override’
    ~QQmlElement() override {
    ^~~~~~~~~

     

    I followed this tutorial: https://qml.guide/enums-in-qt-qml/

     

    My code:

    #ifndef TASKINFOTYPE_H
    #define TASKINFOTYPE_H
    #include <QObject>
    
    class TaskInfoType
    {
        Q_GADGET
    public:
        explicit TaskInfoType();
        static QString getLabel( int infoType );
    
        enum Value{
            COMMENT = 0,
            LOCATION = 100,
            CONTACT = 200,
            AS_IMAGE = 300,
            DOCUMENT = 400,
            DATETIME = 500,
            LINK = 600
        };
        Q_ENUM(Value)
    
    
    };
    
    #endif // TASKINFOTYPE_H
    

     

    What Im doing wrong? The only difference is that I added a method to retrieve a label

     

    #23499

    jrrobles79

    Well my c++ is in very bad shape but I make it work with some changes,  but if somebody explains me why the previous code didn’t workI will thank you very much.

     

    BTW  the method getLabel is not working on qml

     

    #ifndef TASKINFOTYPE_H
    #define TASKINFOTYPE_H
    
    #include <QObject>
    
    class TaskInfoType : public QObject
    {
        Q_OBJECT
    
    public:
        TaskInfoType(QObject *parent = nullptr);
    
        enum Value{
               COMMENT = 0,
               LOCATION = 100,
               CONTACT = 200,
               IMAGE = 300,
               DOCUMENT = 400,
               DATETIME = 500,
               LINK = 600
           };
           Q_ENUM(Value)
    
    public slots:
        static QString getLabel(int infoType);
    
    };
    
    #endif // TASKINFOTYPE_H
    

     

Viewing 2 posts - 1 through 2 (of 2 total)

RSS feed for this thread

You must be logged in to reply to this topic.

Voted #1 for:

  • Easiest to learn
  • Most time saving
  • Best support

Develop Cross-Platform Apps and Games 50% Faster!

  • Voted the best supported, most time-saving and easiest to learn cross-platform development tool
  • Based on the Qt framework, with native performance and appearance on all platforms including iOS and Android
  • Offers a variety of plugins to monetize, analyze and engage users
FREE!
create apps
create games
cross platform
native performance
3rd party services
game network
multiplayer
level editor
easiest to learn
biggest time saving
best support