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. Does not see files in qrc file
Qt 6.11 is out! See what's new in the release blog

Does not see files in qrc file

Scheduled Pinned Locked Moved Unsolved General and Desktop
3 Posts 2 Posters 702 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.
  • serkan_trS Offline
    serkan_trS Offline
    serkan_tr
    wrote on last edited by serkan_tr
    #1

    Screenshot from 2024-10-12 08-35-38.png

    In the image above, my file structure is detected by qt creator and the file location paths are visible. When I try to run the same path as main.cpp, it says there is no file. What is the reason for this?

    qrc file

    <!DOCTYPE RCC>
    <RCC version="1.0">
        <qresource prefix="/icons">
            <file alias="black">assets/icons/black.svg</file>
        </qresource>
        <qresource prefix="/images">
            <file alias="lectron">assets/images/lectron.png</file>
            <file alias="no_video_background">assets/images/NoVideoBackground.jpg</file>
        </qresource>
        <qresource prefix="/qml">
            <file alias="Main.qml">qml/Main.qml</file>
        </qresource>
    </RCC>
    

    e8071252-a63a-4757-9d87-3e8a47ea5dd6-image.png

    cmake file:

    cmake_minimum_required(VERSION 3.16)
    
    project(lectron VERSION 0.1 LANGUAGES CXX)
    
    set(CMAKE_CXX_STANDARD_REQUIRED ON)
    
    find_package(Qt6 6.5 REQUIRED COMPONENTS Quick)
    
    qt_standard_project_setup()
    
    qt_add_executable(applectron
        main.cpp
    )
    
    qt_add_qml_module(applectron
        URI lectron
        VERSION 1.0
        RESOURCES
            source.qrc
    
    )
    
    1 Reply Last reply
    0
    • Christian EhrlicherC Offline
      Christian EhrlicherC Offline
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on last edited by
      #2

      It's qml/qml/Main.qml

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      serkan_trS 1 Reply Last reply
      1
      • Christian EhrlicherC Christian Ehrlicher

        It's qml/qml/Main.qml

        serkan_trS Offline
        serkan_trS Offline
        serkan_tr
        wrote on last edited by serkan_tr
        #3

        @Christian-Ehrlicher I tried this too but it didn't work
        ac0256da-ea55-4d72-bd26-411fe129ba1a-image.png

        I made an assignment in the qrc file using alias, so I wrote one qml

        <qresource prefix="/qml">
                <file alias="Main.qml">qml/Main.qml</file>
            </qresource>
        

        Is there something I'm missing in the cmake file?

        When I delete Main.qml from qrc file and write

        qt_add_qml_module(applectron
        URI lectron
        VERSION 1.0
        QML_FILES
        qml/Main.qml
        

        directly in cmake file, the code works but why doesn't it work in qrc file? What is my error?

        I can't see the images on the qml side either.

        Image {
                id: image
                anchors.fill: parent
                source: "qrc:/images/no_video_background"
                fillMode: Image.Stretch
                z: -1
            }
        
        qrc:/lectron/qml/Main.qml:18:5: QML Image: Cannot open: qrc:/images/no_video_background
        
        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