Reading from and writing to file in The Qt Resource System (qt 5.0.2)

后端 未结 2 894
半阙折子戏
半阙折子戏 2021-02-15 17:55

I have the code below. I am using Qt_5_0_2_MSVC2012_64bit-Release. I am not able to read the file. I get the debug error message of \"Cannot open file for reading\".There is som

相关标签:
2条回答
  • 2021-02-15 18:35

    I had same problem. The Error string was "Unknown error".
    Solution was to add INCLUDEPATH += . from @gatto's answer and run commands from menu:

    1. Build -> Clean all
    2. Build -> Run qmake
    3. Build -> Rebuild All
    
    0 讨论(0)
  • test.pro:

    TEMPLATE = app
    TARGET = test
    INCLUDEPATH += .
    
    # Input
    SOURCES += main.cpp
    RESOURCES += test.qrc
    

    test.qrc:

    <!DOCTYPE RCC><RCC version="1.0">
     <qresource>
        <file>MyFiles/myfile.txt</file>
     </qresource>
     </RCC>
    

    main.cpp is from your question. Works fine.

    That said, if you still have the problem, you should post minimal Qt project (including .pro and .qrc files), that has the error.

    0 讨论(0)
提交回复
热议问题