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. what is the meaning of "qrc::-1 File is empty"

what is the meaning of "qrc::-1 File is empty"

Scheduled Pinned Locked Moved Solved QML and Qt Quick
6 Posts 2 Posters 923 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.
  • H Offline
    H Offline
    hcaslan
    wrote on 22 Sept 2021, 07:56 last edited by
    #1

    I'm trying to learn qt and I encountered such an error in my project, but I couldn't find any examples. Can you help?

    QmlApplicationEngine failed to load component
    qrc::-1 File is empty

    my code at main.cpp

    #include <QGuiApplication>
    #include <QtQml/QQmlApplicationEngine>

    int main(int argc, char *argv[]){
    QGuiApplication app(argc,argv);
    QQmlApplicationEngine engine;
    engine.load(QUrl("qrc://main.qml"));
    return app.exec();
    }

    my code at main.qml

    import QtQuick 2.0
    import QtQuick.Controls 1.0
    import QtQuick.Window 2.0

    ApplicationWindow{
    width: 640
    height: 480
    visible: true

    Text{
        anchors.centerIn: parent
        text: "hello world"
    }
    

    }

    K 1 Reply Last reply 22 Sept 2021, 08:07
    0
    • H Offline
      H Offline
      hcaslan
      wrote on 22 Sept 2021, 08:44 last edited by
      #6

      I found my mistake. I made a mistake while typing the QUrl(it must be three / not two / ). Thanks for your concern. If someone hadn't answered, I would probably have given up.

      1 Reply Last reply
      2
      • H hcaslan
        22 Sept 2021, 07:56

        I'm trying to learn qt and I encountered such an error in my project, but I couldn't find any examples. Can you help?

        QmlApplicationEngine failed to load component
        qrc::-1 File is empty

        my code at main.cpp

        #include <QGuiApplication>
        #include <QtQml/QQmlApplicationEngine>

        int main(int argc, char *argv[]){
        QGuiApplication app(argc,argv);
        QQmlApplicationEngine engine;
        engine.load(QUrl("qrc://main.qml"));
        return app.exec();
        }

        my code at main.qml

        import QtQuick 2.0
        import QtQuick.Controls 1.0
        import QtQuick.Window 2.0

        ApplicationWindow{
        width: 640
        height: 480
        visible: true

        Text{
            anchors.centerIn: parent
            text: "hello world"
        }
        

        }

        K Offline
        K Offline
        KroMignon
        wrote on 22 Sept 2021, 08:07 last edited by
        #2

        @hcaslan said in what is the meaning of "qrc::-1 File is empty":

        Hello and welcome to Qt forum!

        engine.load(QUrl("qrc://main.qml"));

        With this, you want to read main.qml file from resources (cf. https://doc.qt.io/archives/qt-5.11/resources.html).
        Do you have add a resources to your project?
        Is this file part of this resource?

        It is an old maxim of mine that when you have excluded the impossible, whatever remains, however improbable, must be the truth. (Sherlock Holmes)

        H 1 Reply Last reply 22 Sept 2021, 08:13
        0
        • K KroMignon
          22 Sept 2021, 08:07

          @hcaslan said in what is the meaning of "qrc::-1 File is empty":

          Hello and welcome to Qt forum!

          engine.load(QUrl("qrc://main.qml"));

          With this, you want to read main.qml file from resources (cf. https://doc.qt.io/archives/qt-5.11/resources.html).
          Do you have add a resources to your project?
          Is this file part of this resource?

          H Offline
          H Offline
          hcaslan
          wrote on 22 Sept 2021, 08:13 last edited by
          #3

          @KroMignon Yes ı created and added the file "main.qml".
          alt text

          K 1 Reply Last reply 22 Sept 2021, 08:22
          0
          • H hcaslan
            22 Sept 2021, 08:13

            @KroMignon Yes ı created and added the file "main.qml".
            alt text

            K Offline
            K Offline
            KroMignon
            wrote on 22 Sept 2021, 08:22 last edited by
            #4

            @hcaslan said in what is the meaning of "qrc::-1 File is empty":

            Yes ı created and added the file "main.qml".

            And is the resource part of your project?
            Do you use cmake or qmake build system?
            Which Qt version are you using (I mean Qt and not QtCreator)?

            It is an old maxim of mine that when you have excluded the impossible, whatever remains, however improbable, must be the truth. (Sherlock Holmes)

            H 1 Reply Last reply 22 Sept 2021, 08:33
            0
            • K KroMignon
              22 Sept 2021, 08:22

              @hcaslan said in what is the meaning of "qrc::-1 File is empty":

              Yes ı created and added the file "main.qml".

              And is the resource part of your project?
              Do you use cmake or qmake build system?
              Which Qt version are you using (I mean Qt and not QtCreator)?

              H Offline
              H Offline
              hcaslan
              wrote on 22 Sept 2021, 08:33 last edited by
              #5

              @KroMignon cmake build system. And ı use QtCreator. ı have tried this to add resource --> Add new>qt>resource file then add prefix then add files. if that's what you're asking.

              1 Reply Last reply
              0
              • H Offline
                H Offline
                hcaslan
                wrote on 22 Sept 2021, 08:44 last edited by
                #6

                I found my mistake. I made a mistake while typing the QUrl(it must be three / not two / ). Thanks for your concern. If someone hadn't answered, I would probably have given up.

                1 Reply Last reply
                2

                4/6

                22 Sept 2021, 08:22

                • Login

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