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. File Handling in QML
Forum Updated to NodeBB v4.3 + New Features

File Handling in QML

Scheduled Pinned Locked Moved QML and Qt Quick
3 Posts 3 Posters 4.2k Views 1 Watching
  • 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.
  • S Offline
    S Offline
    situ117
    wrote on last edited by
    #1

    Hi,

    Is there any way to do file handling in QML using Javascript or any plugins written in C++ for this purpose ?

    1 Reply Last reply
    0
    • T Offline
      T Offline
      thisisbhaskar
      wrote on last edited by
      #2

      I don't think it is possible, and more over its not suggested to write business logic in JavaScript which effects your application performance.

      1 Reply Last reply
      0
      • L Offline
        L Offline
        L.MCH
        wrote on last edited by
        #3

        You just have to code a QDeclarativeItem subclass in C++ with the methods (and the internal state information like current directory, etc.) you need and register it at runtime so it becomes accessible as a QML Element as described here:
        http://doc.qt.nokia.com/4.7-snapshot/qml-extending.html

        But as Vijay said, you should be very careful how you do it, because if you just expose a few basic file handling methods and then use javascript to code a more complex stuff calling the low level ones, you usually end up with business logic embedded on the UI side of your application.

        For example, if your QML c++ object just provides access to fopen(), fclose(), fprint() functions, you usually end up with lots of javascript code performin loops and calling those functions to decode/encode data etc.

        Better if you define a QDeclarativeItem subclass that performs the file handling operations including most of the complex stuff and then emits a signal when done or exposes a QML ListModel with the result of the operations performed.

        For example, when you change the source property in the QML Image element , the element performs lots of file operations and data conversions, but on the UI side you just get onStatusChanged signals and the UI perform a refresh of the image.

        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