Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. QJSEngine How I can export QDir and QFileInfo to js
Qt 6.11 is out! See what's new in the release blog

QJSEngine How I can export QDir and QFileInfo to js

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
1 Posts 1 Posters 728 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    Avazart7
    wrote on last edited by
    #1

    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

    1 Reply Last reply
    0

    • Login

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved