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. Problem with adding another qml file
Forum Updated to NodeBB v4.3 + New Features

Problem with adding another qml file

Scheduled Pinned Locked Moved Solved QML and Qt Quick
4 Posts 2 Posters 290 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.
  • A Offline
    A Offline
    apaczenko1993
    wrote on 21 Aug 2024, 07:48 last edited by
    #1

    Hello

    I have problem with adding another qml file to my project.
    Generally I have main.qml file with main window and second qml file named kafelek.qml with Item, but after adding this file to my project and resource i have error like this:

    QQmlApplicationEngine failed to load component
    qrc:/WebAPT/main.qml:145:25: Kafelek is not a type
    

    Below screenshot with prove, that my second qml file is added to resource, how can i fix it?

    qt.jpg

    1 Reply Last reply
    0
    • D Offline
      D Offline
      Durugesha
      wrote on 21 Aug 2024, 13:02 last edited by
      #2

      By looking at the file structure, QML folder also has two files with same name and .qrc file also has two file with the same name, can you remove QML file folder(by right click on the kafelek, and main.qml) and chage the main.qml qrc path in main.cpp so main.cpp loads main.qml from .qrc file. . both qml files resides in .qrc file and you are free to go.

      1 Reply Last reply
      0
      • D Offline
        D Offline
        Durugesha
        wrote on 21 Aug 2024, 13:26 last edited by Durugesha
        #3

        /home/justin/Pictures/Screenshots/Screenshot from 2024-08-21 18-53-03.png
        this file structure helps you to solve your issue.
        Screenshot from 2024-08-21 18-53-03.png

        1 Reply Last reply
        0
        • A Offline
          A Offline
          apaczenko1993
          wrote on 22 Aug 2024, 11:39 last edited by
          #4

          I found solution without creating resource. The pro file must by eddited like this with example in my example with Kafelek.qml
          After space write filename with extension in resource.files :)

          QT += quick
          
          SOURCES += \
                  main.cpp
          
          resources.files = main.qml Kafelek.qml
          resources.prefix = /$${TARGET}
          RESOURCES += resources
          
          
          # Additional import path used to resolve QML modules in Qt Creator's code model
          QML_IMPORT_PATH =
          
          # Additional import path used to resolve QML modules just for Qt Quick Designer
          QML_DESIGNER_IMPORT_PATH =
          
          # Default rules for deployment.
          qnx: target.path = /tmp/$${TARGET}/bin
          else: unix:!android: target.path = /opt/$${TARGET}/bin
          !isEmpty(target.path): INSTALLS += target
          
          DISTFILES += \
              Kafelek.qml \
              images/logo.png
          
          
          1 Reply Last reply
          0
          • A apaczenko1993 has marked this topic as solved on 22 Aug 2024, 11:39

          1/4

          21 Aug 2024, 07:48

          • Login

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