Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Installation and Deployment
  4. [this one sucks] Application works only in specific folder, exits silently in another folder
Qt 6.11 is out! See what's new in the release blog

[this one sucks] Application works only in specific folder, exits silently in another folder

Scheduled Pinned Locked Moved Installation and Deployment
31 Posts 5 Posters 15.2k 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.
  • H Offline
    H Offline
    Hedge
    wrote on last edited by
    #15

    setSource requires a QUrl.

    1 Reply Last reply
    0
    • P Offline
      P Offline
      Peppy
      wrote on last edited by
      #16

      QString is so beautiful class, isn't it?

      1 Reply Last reply
      0
      • A Offline
        A Offline
        andre
        wrote on last edited by
        #17

        [quote author="Hedge" date="1305721995"]setSource requires a QUrl.[/quote]

        Sorry, you are right. But you did not read the docs quite well either:

        [quote]Ensure that the URL provided is full and correct, in particular, use QUrl::fromLocalFile() when loading a file from the local filesystem.[/quote]

        1 Reply Last reply
        0
        • H Offline
          H Offline
          Hedge
          wrote on last edited by
          #18

          Sorry, that I didn't mention this earlier but that is a problem since my qrc-file is compiled into the executable-file by this entry in the .pro-file:

          @# Compile Resources in Binary
          RESOURCES +=
          resources.qrc@

          So
          @viewer.setSource(QUrl::fromLocalFile(":/main.qml"));@

          doesn't work in this case, because it seems to look for a real file.

          The error is

          @file:///D:/MyProject/:/main.qml: File not found @

          1 Reply Last reply
          0
          • A Offline
            A Offline
            andre
            wrote on last edited by
            #19

            Could you show us the contents of your resources.qrc file?

            1 Reply Last reply
            0
            • H Offline
              H Offline
              Hedge
              wrote on last edited by
              #20

              Yeah, no problem.

              @<RCC>
              <qresource prefix="/">
              <file>main.qml</file>
              <file>images/haken_gruen.gif</file>
              <file>images/connected.png</file>
              <file>images/not-connected.png</file>
              <file>desktop-components/components/plugin/libstyleplugin.a</file>
              <file>desktop-components/components/Button.qml</file>
              <file>desktop-components/components/ButtonRow.qml</file>
              <file>desktop-components/components/CheckBox.qml</file>
              <file>desktop-components/components/ChoiceList.qml</file>
              <file>desktop-components/components/components.pro</file>
              <file>desktop-components/components/ContextMenu.qml</file>
              <file>desktop-components/components/Dial.qml</file>
              <file>desktop-components/components/Frame.qml</file>
              <file>desktop-components/components/GroupBox.qml</file>
              <file>desktop-components/components/Makefile</file>
              <file>desktop-components/components/ProgressBar.qml</file>
              <file>desktop-components/components/qmldir</file>
              <file>desktop-components/components/RadioButton.qml</file>
              <file>desktop-components/components/ScrollArea.qml</file>
              <file>desktop-components/components/ScrollBar.qml</file>
              <file>desktop-components/components/Slider.qml</file>
              <file>desktop-components/components/SpinBox.qml</file>
              <file>desktop-components/components/Switch.qml</file>
              <file>desktop-components/components/Tab.qml</file>
              <file>desktop-components/components/TabBar.qml</file>
              <file>desktop-components/components/TabFrame.qml</file>
              <file>desktop-components/components/TableView.qml</file>
              <file>desktop-components/components/TextArea.qml</file>
              <file>desktop-components/components/TextField.qml</file>
              <file>desktop-components/components/ToolBar.qml</file>
              <file>desktop-components/components/ToolButton.qml</file>
              <file>desktop-components/components/custom/BasicButton.qml</file>
              <file>desktop-components/components/custom/Button.qml</file>
              <file>desktop-components/components/custom/ButtonColumn.qml</file>
              <file>desktop-components/components/custom/ButtonGroup.js</file>
              <file>desktop-components/components/custom/ButtonRow.qml</file>
              <file>desktop-components/components/custom/CheckBox.qml</file>
              <file>desktop-components/components/custom/ChoiceList.qml</file>
              <file>desktop-components/components/custom/components.pro</file>
              <file>desktop-components/components/custom/GroupBox.qml</file>
              <file>desktop-components/components/custom/ProgressBar.qml</file>
              <file>desktop-components/components/custom/qmldir</file>
              <file>desktop-components/components/custom/Slider.qml</file>
              <file>desktop-components/components/custom/SpinBox.qml</file>
              <file>desktop-components/components/custom/TextField.qml</file>
              <file>desktop-components/components/custom/behaviors/ButtonBehavior.qml</file>
              <file>desktop-components/components/custom/behaviors/ModalPopupBehavior.qml</file>
              <file>desktop-components/components/custom/private/ChoiceListPopup.qml</file>
              </qresource>
              </RCC>
              @

              1 Reply Last reply
              0
              • G Offline
                G Offline
                giesbert
                wrote on last edited by
                #21

                Hi Hedge,

                this

                @
                <qresource prefix="/">
                @

                is not needed, it could be

                @
                <qresource prefix="">
                @

                Nokia Certified Qt Specialist.
                Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz)

                1 Reply Last reply
                0
                • H Offline
                  H Offline
                  Hedge
                  wrote on last edited by
                  #22

                  Thanks for the suggestion. That doesn't fix the problem though.
                  Do you have other suggestions?

                  1 Reply Last reply
                  0
                  • G Offline
                    G Offline
                    goetz
                    wrote on last edited by
                    #23

                    This works for me:

                    ------ main.cpp ------
                    @

                    #include <QtGui/QApplication>
                    #include <QDeclarativeView>

                    int main(int argc, char *argv[])
                    {
                    QApplication app(argc, argv);

                    QDeclarativeView view;
                    view.setSource(QUrl("qrc:/qml/QMLwithResource/main.qml"));
                    view.show();-
                    
                    return app.exec();
                    

                    }
                    @

                    ------ qmlresource.qrc ------
                    @
                    <RCC>
                    <qresource prefix="/">
                    <file>qml/QMLwithResource/main.qml</file>
                    </qresource>
                    </RCC>
                    @

                    Watch out if you use the autogenerated qmlapplicationviewer, it has a setMainQmlFile which takes a QString as argument. On the Mac the path is adjusted to look into the AppBundle.app/Contents/Resources directory. You might want to adjust that class to take a QUrl as argument.

                    http://www.catb.org/~esr/faqs/smart-questions.html

                    1 Reply Last reply
                    0
                    • H Offline
                      H Offline
                      Hedge
                      wrote on last edited by
                      #24

                      Hello Volker. The problem must be the:

                      @import "desktop-components/components"@

                      inside the main.qml file. It works without it (I replaced the whole GUI with just a rectangle).

                      1 Reply Last reply
                      0
                      • G Offline
                        G Offline
                        goetz
                        wrote on last edited by
                        #25

                        It works for me too (all in resources, no access to files on the disk):

                        @
                        <RCC>
                        <qresource prefix="/">
                        <file>qml/QMLwithResource/main.qml</file>
                        <file>qml/QMLwithResource/parts/FancyText.qml</file>
                        </qresource>
                        </RCC>
                        @

                        In main.qml I have :

                        @
                        import QtQuick 1.0
                        import "parts"

                        Rectangle {
                        width: 360
                        height: 360
                        Text {
                        id: ttt
                        text: "Hello World"
                        anchors.centerIn: parent
                        }
                        Text {
                        id: blurb
                        text: "blurb"
                        anchors.top: ttt.bottom
                        anchors.horizontalCenter: parent.horizontalCenter
                        }
                        FancyText {
                        id: ft
                        anchors.top: blurb.bottom
                        anchors.horizontalCenter: parent.horizontalCenter
                        }

                        MouseArea {
                            anchors.fill: parent
                            onClicked: {
                                Qt.quit();
                            }
                        }
                        

                        }
                        @

                        FancyText.qml is

                        @
                        import QtQuick 1.0

                        Item {
                        id: fancyTextId
                        width: 100
                        height: 62
                        Text {
                        id: fancytextid
                        text: "This is a fancy text"
                        }
                        }
                        @

                        You can add this snippet to your main.cpp, at the beginning. It shows you in which paths the qml files are searched for:

                        @
                        QByteArray data = "1";
                        qputenv("QML_IMPORT_TRACE", data);
                        @

                        http://www.catb.org/~esr/faqs/smart-questions.html

                        1 Reply Last reply
                        0
                        • H Offline
                          H Offline
                          Hedge
                          wrote on last edited by
                          #26

                          @ QByteArray data = "1";
                          qputenv("QML_IMPORT_TRACE", data);
                          qDebug() << data;@

                          Output is "1" still.

                          You've spend so much time with my project.
                          I hope I can make it to the Qt Summit and spend a beer.

                          Now that you already have a test-setup why don't you try the desktop-components http://qt.gitorious.org/qt-components/desktop (release-build + move exe to another folder).

                          I smell there's some bullshit going on there because when I run the release-build exe through Qt's debugger there occurs an error within styleplugin.dll .

                          1 Reply Last reply
                          0
                          • H Offline
                            H Offline
                            Hedge
                            wrote on last edited by
                            #27

                            bump New day, new ideas?

                            1 Reply Last reply
                            0
                            • G Offline
                              G Offline
                              goetz
                              wrote on last edited by
                              #28

                              Sorry, I was too busy today. I didn't forget your issue - stay tuned :)

                              http://www.catb.org/~esr/faqs/smart-questions.html

                              1 Reply Last reply
                              0
                              • H Offline
                                H Offline
                                Hedge
                                wrote on last edited by
                                #29

                                This wasn't specifically referring to you.

                                I'm tuning the OSX-version in the meantime.
                                Oh btw. I don't have this problem on OSX. I can put the app anywhere and it works fine.

                                1 Reply Last reply
                                0
                                • H Offline
                                  H Offline
                                  Hedge
                                  wrote on last edited by
                                  #30

                                  Ok I did another try.
                                  This time I added ALL files of desktop-components to the qrc-file (even the dll which isn't supposed to be there) but still no luck.

                                  It's clearly the line import "desktop-components/components" in main.qml which make the application crash.

                                  1 Reply Last reply
                                  0
                                  • G Offline
                                    G Offline
                                    goetz
                                    wrote on last edited by
                                    #31

                                    DLLs cannot be loaded from qrc files anyways - it will just bloat the exe. I still need my MinGW environment to check on a Windows box :)

                                    http://www.catb.org/~esr/faqs/smart-questions.html

                                    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