Learn what Felgo offers to help your business succeed. Start your free evaluation today! Felgo for Your Business

Forums

OverviewFelgo 3 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.

Qt_Technology_Partner_RGB_475 Qt_Service_Partner_RGB_475_padded