Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. [Solved] [Qt5] How register my own QIODevice (replacement of QAbstractFileEngineHandler)
Forum Updated to NodeBB v4.3 + New Features

[Solved] [Qt5] How register my own QIODevice (replacement of QAbstractFileEngineHandler)

Scheduled Pinned Locked Moved General and Desktop
16 Posts 2 Posters 4.8k 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.
  • F Offline
    F Offline
    Flamaros
    wrote on last edited by
    #3

    Thank you, because for the moment I have some include path with the version number of Qt.

    It seems working fine else, I just have some difficulties to make the QML engine loading correctly my files. I don't know exactly why but it fails load a component. Three previous loaded files by the QML engine are the root QML containing a loader to the main.qml that import a js can correctly loaded too.

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #4

      You should note have such includes. Either use

      @#include <QtCore/QObject>@

      or just

      @#include <QObject>@

      But no version number

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • F Offline
        F Offline
        Flamaros
        wrote on last edited by
        #5

        Thank you a lot, it's much better now.

        May have you an idea on what can cause the qml engine not finding components?

        Here is my logs :
        @
        D/Qt ( 5463): ....\Source\GUI_QML\ResourcesDevice.cpp:279 (virtual void qml::ResourcesEngine::setFileName(const QString&)): ResourcesEngine::setFileName : "main.1.fr.anuman.HomeDesign3D.obb/qml/Main.qml"
        D/Qt ( 5463): ....\Source\GUI_QML\ResourcesDevice.cpp:279 (virtual void qml::ResourcesEngine::setFileName(const QString&)): ResourcesEngine::setFileName : "main.1.fr.anuman.HomeDesign3D.obb/qml/Utils.js"
        D/Qt ( 5463): ....\Source\GUI_QML\ResourcesDevice.cpp:279 (virtual void qml::ResourcesEngine::setFileName(const QString&)): ResourcesEngine::setFileName : "main.1.fr.anuman.HomeDesign3D.obb/qml"
        W/Qt ( 5463): file:///data/data/fr.anuman.HomeDesign3D/files/main.1.fr.anuman.HomeDesign3D.obb/qml/Main.qml:17 ((null)): file:///data/data/fr.anuman.HomeDesign3D/files/main.1.fr.anuman.HomeDesign3D.obb/qml/Main.qml:17:5: ProjectInfo is not a type
        @

        ProjectInfo component is in the "main.1.fr.anuman.HomeDesign3D.obb/qml" folder for which I return fileFlags : All read permissions, exists, directory and all execution permissions.
        I got the error just after the last call of my QAbstractFileEngine::fileFlags(FileFlags type) implementation.

        1 Reply Last reply
        0
        • F Offline
          F Offline
          Flamaros
          wrote on last edited by
          #6

          We also using cmake, do you know how I import a private module with it?

          I tried that :
          find_package(Qt5Core ${QT_MIN_VERSION} REQUIRED Private)

          without success.

          My header #include <QtCore/private/qabstractfileengine_p.h> can't be found.

          1 Reply Last reply
          0
          • SGaistS Offline
            SGaistS Offline
            SGaist
            Lifetime Qt Champion
            wrote on last edited by
            #7

            Without any code, initialization etc… I can't tell

            Interested in AI ? www.idiap.ch
            Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

            1 Reply Last reply
            0
            • F Offline
              F Offline
              Flamaros
              wrote on last edited by
              #8

              I finally made it work on Windows, but not Android that is my main target for the moment.
              The issue was my read implementation that didn't return the correct size cause I mess the check of the end of file.
              I am using the same code and package file on android but I still have the same issue.

              What part of code do you need?

              Is there a way to associate Qt code to the debugger to be able to understand where it failed to load the component and for what condition? That was the method I used to find the issue on read implementation.

              1 Reply Last reply
              0
              • SGaistS Offline
                SGaistS Offline
                SGaist
                Lifetime Qt Champion
                wrote on last edited by
                #9

                You can use the debugger the same way

                The implementation of your custom file engine handler, however it might be easier if the code is big to either use a pastbin site or if you have a repository to look at

                Interested in AI ? www.idiap.ch
                Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                1 Reply Last reply
                0
                • F Offline
                  F Offline
                  Flamaros
                  wrote on last edited by
                  #10

                  I had try to add mapping to Qt sources to the debugger, but I am not able to see it, QtCreator always show me the asm of Qt.

                  I have found a little workaround, I can load qml files from the user backup directory and images from my package, so the issue seems to be specific of the way qml files are loaded. I certainly do something wrong with text file that cause some parsing issues, but it strange in this case that it's works on Windows.

                  Here is my implementation of the QAbstractFileEngine :
                  http://pastebin.com/ZnMFVdDV
                  http://pastebin.com/rf9wuein

                  1 Reply Last reply
                  0
                  • SGaistS Offline
                    SGaistS Offline
                    SGaist
                    Lifetime Qt Champion
                    wrote on last edited by
                    #11

                    @mCurrentDir = QDir::current().path() + "/";@

                    Looks dangerous to me, it's probably not what you assume it is on android

                    Interested in AI ? www.idiap.ch
                    Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                    1 Reply Last reply
                    0
                    • F Offline
                      F Offline
                      Flamaros
                      wrote on last edited by
                      #12

                      I have a question about the QFileInfo QAbstractFileEngineIterator::currentFileInfo() const method.
                      How the implementation made in my derived class can generate a QFileInfo with right properties? Like if the entry is a file or a directory?

                      1 Reply Last reply
                      0
                      • F Offline
                        F Offline
                        Flamaros
                        wrote on last edited by
                        #13

                        [quote author="SGaist" date="1410898531"]@mCurrentDir = QDir::current().path() + "/";@

                        Looks dangerous to me, it's probably not what you assume it is on android[/quote]

                        You are right, it's certainly better for my to check if the path contains my package name then removing everything before to clean file path.

                        1 Reply Last reply
                        0
                        • SGaistS Offline
                          SGaistS Offline
                          SGaist
                          Lifetime Qt Champion
                          wrote on last edited by
                          #14

                          If you want you own application folder your can use Q(Gui)Application for that.

                          Interested in AI ? www.idiap.ch
                          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                          1 Reply Last reply
                          0
                          • F Offline
                            F Offline
                            Flamaros
                            wrote on last edited by
                            #15

                            [quote author="SGaist" date="1410986525"]If you want you own application folder your can use Q(Gui)Application for that.[/quote]

                            Yes we already use it for some other things.

                            Thank you a lot for all of your help.

                            How I can mark this thread a resolved?

                            1 Reply Last reply
                            0
                            • SGaistS Offline
                              SGaistS Offline
                              SGaist
                              Lifetime Qt Champion
                              wrote on last edited by
                              #16

                              You're welcome !

                              Just edit your original post and update the thread title :)

                              Interested in AI ? www.idiap.ch
                              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                              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