QJSEngine How I can export QDir and QFileInfo to js



  • I have a code:

    #include <QObject>
    #include <QDir>
    
    // wrapper QDir for js
    class Dir : public QObject
    {
       Q_OBJECT
    public:
        /*
        enum Filter { Dirs        = 0x001,
                      Files       = 0x002,
                      Drives      = 0x004,
                      ...
         
                      
        enum SortFlag { Name        = 0x00,
                        Time        = 0x01,
                        Size        = 0x02,
                      ...                    
        */
        
        // ...
        QStringList entryList1(const QStringList &nameFilters, 
              QDir::Filters filters = QDir::NoFilter  /* ??? */, 
              QDir::SortFlags sort =  QDir::NoSort    /* ??? */) const
        {
          return dir_.entryList(filters,SortFlags);       
        }
                                  
        
    private:
        QDir dir_;    
    };
    
    
    QSharedPointer<QJSEngine> jsEngine(new QJSEngine);
     
    QJSValue jsDir = jsEngine->newQMetaObject<Dir>();
    jsEngine->globalObject().setProperty("Dir",jsDir);
    
    QJSValue result = jsEngine->evaluate(JsScript);
    
    // JsScript
    var d = new Dir("D:/SomeDir"); 
       var files = d.entryList1(QDir.Files);   /* ??? */
    for(i in files)
    {
      log.addInfo(files[i]);
    }  
    

    I have a proplem with enums QDir::Filter and QDir::SortFlag
    and method containing them


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.