Forums

OverviewFelgo 2 Support (Qt 5) › Error importing an enum from c++ class

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

    jrrobles79

    Hi,I have the next enum that I created to organize my console.log :

    #ifndef MYLOGTYPE_H
    #define MYLOGTYPE_H
    
    #include <QObject>
    
    class MyLogType: public QObject
    {
         Q_OBJECT
    
    public:
        MyLogType(QObject *parent = nullptr);
        enum Value{
               ERROR = 10,
               INFO = 20,
               LOG = 30,
               DEBUG = 40,
               WARN = 50
              };
              Q_ENUM(Value)
    };
    
    #endif // MYLOGTYPE_H
    

     

    I imported it, like any other c++ class:

      qmlRegisterType<MyLogType>("com.iubo.app.types.mylogtype", 1, 0, "MyLogType");

     

    on viewhelper.qml

     

    import com.iubo.app.types.mylogtype 1.0
    import QtQuick 2.0
    import Felgo 3.0
    
    ...
    ...
    
    function logMyEvent (  logType,  componentName, functionName, msg){
            switch(logType){
            case MyLogType.WARN:
                  console.warn( componentName+":"+functionName+" msg:" + msg )
                  break;
            case MyLogType.ERROR:
                  console.error( componentName+":"+functionName+" msg:" + msg )
                  break;
            case MyLogType.INFO:
                  console.info( componentName+":"+functionName+" msg:" + msg )
                  break;
            case MyLogType.LOG:
                  console.log( componentName+":"+functionName+" msg:" + msg )
                  break;
            case MyLogType.DEBUG:
            default:
                  console.debug( componentName+":"+functionName+" msg:" + msg )
                  break;
            }
            return;
        }

     

    Even when I type ‘MyLogType. ' on my QML the correct values of the enums are showed Im getting this error:

    Warning: QML import could not be resolved in any of the import paths: com.iubo.app.types.mylogtype

    and on the app shows: “viewHelper.qml:1:1: modulecom.iubo.app.types.mylogtype is not installed"

    I cleaned, rebuild and qmake my project but I don’t see the error, is the same procedure I have done for other classes.

     

    #23511

    jrrobles79
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