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. using QML Pages as items in main.qml
Forum Updated to NodeBB v4.3 + New Features

using QML Pages as items in main.qml

Scheduled Pinned Locked Moved Unsolved General and Desktop
5 Posts 4 Posters 251 Views
  • 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.
  • M Offline
    M Offline
    MaximBozek
    wrote on last edited by
    #1

    Hi,

    I used to be able to make my qml page, for example Can.qml. Then I would call this whole qml as a item in main.qml to be able to access variable created in main.qml in Can.qml:

    Can  {
        id: can_page
        visible: false
    }
    

    Now for some reason, I get this error: qrc:/Test_Project_Display/main.qml:41:5: Can is not a type
    How can I fix this?

    1 Reply Last reply
    0
    • H Offline
      H Offline
      Harsha P
      wrote on last edited by
      #2

      Hi @MaximBozek,

      This issue may be caused by Can.qml not being added to qml.qrc. When a new QML file is created, it should automatically be included in the resource file(qml.qrc). If it is missing, you may encounter the error: "Can is not a type".

      <RCC>
      <qresource prefix="/">
      <file>main.qml</file>
      <file>Can.qml</file>
      </qresource>
      </RCC>

      M 1 Reply Last reply
      0
      • H Harsha P

        Hi @MaximBozek,

        This issue may be caused by Can.qml not being added to qml.qrc. When a new QML file is created, it should automatically be included in the resource file(qml.qrc). If it is missing, you may encounter the error: "Can is not a type".

        <RCC>
        <qresource prefix="/">
        <file>main.qml</file>
        <file>Can.qml</file>
        </qresource>
        </RCC>

        M Offline
        M Offline
        MaximBozek
        wrote on last edited by
        #3

        @Harsha-P

        Hi, sorry for replying so late, been busy with other projects in the mean time. My project has this strcuture:

        053af80d-964e-4cb9-941c-4028918030b0-image.png

        there is no such qml.qrc file in my project. I tried putting a new .qml file in that same folder as main.qml, but this didn't work either.

        JoeCFDJ 1 Reply Last reply
        0
        • C Offline
          C Offline
          csw_control
          wrote on last edited by
          #4
          This post is deleted!
          1 Reply Last reply
          0
          • M MaximBozek

            @Harsha-P

            Hi, sorry for replying so late, been busy with other projects in the mean time. My project has this strcuture:

            053af80d-964e-4cb9-941c-4028918030b0-image.png

            there is no such qml.qrc file in my project. I tried putting a new .qml file in that same folder as main.qml, but this didn't work either.

            JoeCFDJ Offline
            JoeCFDJ Offline
            JoeCFD
            wrote on last edited by JoeCFD
            #5

            @MaximBozek If there is no qrc file, create one and add qrc file to your project. Add all qml files into the qrc file.

            you may need a few, for example, one for images, one for qml files and one for xml files, etc.

            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