Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. Not able to run basic example with UI in qt

Not able to run basic example with UI in qt

Scheduled Pinned Locked Moved Solved Mobile and Embedded
4 Posts 2 Posters 335 Views 2 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.
  • U Offline
    U Offline
    ujur007
    wrote on last edited by ujur007
    #1

    I am trying to build a basic qt example from the following link. The example has main.cpp file and some .qml files in the folder. By default .qml files are in the folder /Resources/qml.qrc//application.qml.

    When I build the program the UI loads but it is not what is expected. I can not see the UI with a rectangle with red color. Can someone help?

    https://doc.qt.io/qt-5/qtquick-deployment.html

    In the application output window, I see the following error
    file:///user/build-untitled2-Desktop_Qt_5_12_12_GCC_64bit-Debug/application.qml: No such file or directory

    1 Reply Last reply
    0
    • U Offline
      U Offline
      ujur007
      wrote on last edited by
      #4

      Okey, I found the error was in main.cpp file. The solution is to do something like the following.

      view.setSource(QUrl("qrc:/myapplication.qml"));

      1 Reply Last reply
      1
      • sierdzioS Offline
        sierdzioS Offline
        sierdzio
        Moderators
        wrote on last edited by
        #2

        A common way to deploy QMLs is to simply store them in a QRC file. Then they will never get lost, regardless of build system settings.

        (Z(:^

        1 Reply Last reply
        0
        • U Offline
          U Offline
          ujur007
          wrote on last edited by ujur007
          #3

          My application is still not able to find the .qml files.! here is a screenshot of what I have in the project.

          Screenshot from 2022-02-01 12-14-07.png

          I have the following in the .pro file of my project

          SOURCES +=
          main.cpp

          RESOURCES +=
          resource.qrc

          DISTFILES +=
          SquareButton.qml
          myapplication.qml
          main.qml

          The last thing is that from my main.cpp I do something like the following, but the files are not found.
          view.setSource(QUrl::fromLocalFile("qrc:/main.qml"));

          1 Reply Last reply
          0
          • U Offline
            U Offline
            ujur007
            wrote on last edited by
            #4

            Okey, I found the error was in main.cpp file. The solution is to do something like the following.

            view.setSource(QUrl("qrc:/myapplication.qml"));

            1 Reply Last reply
            1

            • Login

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