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. [QML Runtime Tool - Qt 6.2] Using dummydata folder
Forum Updated to NodeBB v4.3 + New Features

[QML Runtime Tool - Qt 6.2] Using dummydata folder

Scheduled Pinned Locked Moved Solved QML and Qt Quick
5 Posts 3 Posters 84 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.
  • N Offline
    N Offline
    nico88desmo
    wrote last edited by
    #1

    Hi everybody,

    I'm prototyping some UI QML files using qml runtime tool: regarding model data, I'd like using dummydata folder as used using old qmlscene tool.

    Using the same setup, if I'm using qmlscene, everything correctly works; using qml instead, dummy model data isn't load.

    Using the comman qml --help, options dummydata exists, however it seems not working as expected.

    /usr/local/Qt-6.2.7/bin/qml --help
    Usage: /usr/local/Qt-6.2.7/bin/qml [options] [files...] [-- args...]
    
    Options:
      -h, --help                       Displays help on commandline options.
      --help-all                       Displays help including Qt specific options.
      -v, --version                    Displays version information.
      -a, --apptype <core|gui|widget>  Select which application class to use.
                                       Default is gui.
      -I <path>                        Prepend the given path to the import paths.
      -f <file>                        Load the given file as a QML file.
      -c, --config <file>              Load the given built-in configuration or
                                       configuration file.
      --list-conf                      List the built-in configurations.
      --translation <file>             Load the given file as the translations
                                       file.
      --dummy-data <file>              Load QML files from the given directory as
                                       context properties.
      --desktop                        Force use of desktop OpenGL
                                       (AA_UseDesktopOpenGL).
      --gles                           Force use of GLES (AA_UseOpenGLES).
      --software                       Force use of software rendering
                                       (AA_UseSoftwareOpenGL).
      --core-profile                   Force use of OpenGL Core Profile.
      --disable-context-sharing        Disable the use of a shared GL context for
                                       QtQuick Windows
      --quiet                          Suppress all output.
      --verbose                        Print information about what qml is doing,
                                       like specific file URLs being loaded.
      --slow-animations                Run all animations in slow motion.
      --fixed-animations               Run animations off animation tick rather
                                       than wall time.
      -r, --rhi <backend>              Set the backend for the Qt graphics
                                       abstraction (RHI). Backend is one of:
                                       default, vulkan, metal, d3d11, gl
      -S <selector>                    Add selector to the list of
                                       QQmlFileSelectors.
    
    Arguments:
      files                            Any number of QML files can be loaded. They
                                       will share the same engine.
      args                             Arguments after '--' are ignored, but passed
                                       through to the application.arguments variable
                                       in QML.
    

    The folder structure used respects the following one:

    project
    ├── Main.qml
    └── dummydata/
        └── SampleModel.qml
    

    where SampleModel.qml is the following

    import QtQuick
    
    ListModel {
        ListElement {
            name: "Prova 1"
            printingTimeS: 50
            details: "Prova 1 description"
        }
        ListElement {
            name: "Prova 2"
            printingTimeS: 20
            details: "Prova 2 description"
        }
    }
    

    and Main.qml has the following piece of code:

    ...
    
       ListView {
           anchors.fill: parent
    
           model: SampleModel
    
           delegate: Column {
               Text { text: "Nome: " + name }
               Text { text: "Tempo: " + printingTimeS + "s" }
               Text { text: "Dettagli: " + details }
           }
       }
    ...
    

    I don't find anything on official Qt documentation regarding this aspect.

    Any idea?

    Thanks in advance,
    Nicola

    1 Reply Last reply
    0
    • SGaistS SGaist

      Hi,

      Just a shot in the dark based on the documentation of qmlscene but: try renaming your file sampleModel.qml and apply the same logic in the code.

      N Offline
      N Offline
      nico88desmo
      wrote last edited by nico88desmo
      #3

      @SGaist I try renaming SampleModel.qml to sampleModel.qml, but qml is not able to load dummy model.

      However, I find the solution watching qml tool source code.
      Using Qt 6.2, the solution to load dummy-data is the following: supposing this folder structure

      project
      ├── Main.qml
      └── dummydata/
          └── SampleModel.qml
      

      the steps are:

      1. set project folder as workdir (so, qml need to be execute within project path)
      2. execute the command
        qml --dummy-data . Main.qml

      Important note: since Qt 6.3, dummy-data options seems marked obsolete (from qml source code)

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

        Hi,

        Just a shot in the dark based on the documentation of qmlscene but: try renaming your file sampleModel.qml and apply the same logic in the code.

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

        N 1 Reply Last reply
        0
        • SGaistS SGaist

          Hi,

          Just a shot in the dark based on the documentation of qmlscene but: try renaming your file sampleModel.qml and apply the same logic in the code.

          N Offline
          N Offline
          nico88desmo
          wrote last edited by nico88desmo
          #3

          @SGaist I try renaming SampleModel.qml to sampleModel.qml, but qml is not able to load dummy model.

          However, I find the solution watching qml tool source code.
          Using Qt 6.2, the solution to load dummy-data is the following: supposing this folder structure

          project
          ├── Main.qml
          └── dummydata/
              └── SampleModel.qml
          

          the steps are:

          1. set project folder as workdir (so, qml need to be execute within project path)
          2. execute the command
            qml --dummy-data . Main.qml

          Important note: since Qt 6.3, dummy-data options seems marked obsolete (from qml source code)

          1 Reply Last reply
          0
          • N nico88desmo has marked this topic as solved
          • GrecKoG Offline
            GrecKoG Offline
            GrecKo
            Qt Champions 2018
            wrote last edited by GrecKo
            #4

            Instead of using --dummy-data you could provide a module with a SampleModel singleton and use different import paths depending on if you want an actual model or a mock one.

            N 1 Reply Last reply
            0
            • GrecKoG GrecKo

              Instead of using --dummy-data you could provide a module with a SampleModel singleton and use different import paths depending on if you want an actual model or a mock one.

              N Offline
              N Offline
              nico88desmo
              wrote last edited by
              #5

              @GrecKo that was the other idea.

              But It means creating a QML module just for dummy model used for ui prototype; and I don't like to release that module on production code.

              Example

              Form.ui.qml

              import com.myrealmodule
              import com.mydummymodule
              ...
              // Here I use singleton for dummy data
              ...
              

              However if I don't release that dummy module, clearly I have runtime problem when application starts, cause it.s not able to find It.

              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