• 5542阅读
  • 6回复

[讨论]QT5.0 MSVC2010 资源文件总是提示File not found [复制链接]

上一主题 下一主题
离线libadingzi
 

只看楼主 倒序阅读 楼主  发表于: 2012-12-13
搞了一天真的蛋痛.....最惨的是,痛完之后还是搞不定....
我使用QT5.0 MSVC2010,QT Creator2.6.0创建Qt Quick 1.0的程序,将QML放到资源文件里,可以说网上所有说的方法都试遍了,但程序运行时还是出现File not found的提示,下面是我上个帧子的地址:http://www.qtcn.org/bbs/read-htm-tid-52036.html

下面是main.cpp
#include <QApplication>
#include "qmlapplicationviewer.h"

Q_DECL_EXPORT int main(int argc, char *argv[])
{
    QScopedPointer<QApplication> app(createApplication(argc, argv));
    //Q_INIT_RESOURCE(qmlres);
    QmlApplicationViewer viewer;
    viewer.setOrientation(QmlApplicationViewer::ScreenOrientationAuto);
    //viewer.setSource(QUrl("qrc:/qml/qml/MainForm.qml"));
    viewer.setMainQmlFile(QString(":/qml/mainForm"));
    viewer.showExpanded();

    return app->exec();
}
下面是资源文件
<RCC>
    <qresource prefix="/qml">
        <file alias="mainForm">qml/MainForm.qml</file>
    </qresource>
</RCC>

弄了一天还是没搞定,下面是程序运行再退出后的打印信息
D:\work\products\MHoust\MHoust-build-Desktop-Release\release\MHoust.exe 启动中...
file:///D:/work/products/MHoust/MHoust-build-Desktop-Release/file:///qml/mainForm: File not found
D:\work\products\MHoust\MHoust-build-Desktop-Release\release\MHoust.exe 退出,退出代码: 0

现在初步怀疑是不是字符集编码的原因,QT Creator是UTF-8,但MS 的编译器记得都是UNICODE的,但不知道如何验证,各位大侠,给点提示。。。



离线libadingzi

只看该作者 1楼 发表于: 2012-12-13
初充:下面是工程文件
# Add more folders to ship with the application, here
folder_01.source = qml
folder_01.target = qml
DEPLOYMENTFOLDERS = folder_01

# Additional import path used to resolve QML modules in Creator's code model
QML_IMPORT_PATH =

# If your application uses the Qt Mobility libraries, uncomment the following
# lines and add the respective components to the MOBILITY variable.
# CONFIG += mobility
# MOBILITY +=

# Speed up launching on MeeGo/Harmattan when using applauncherd daemon
# CONFIG += qdeclarative-boostable

# The .cpp file which was generated for your project. Feel free to hack it.
SOURCES += main.cpp

# Please do not modify the following two lines. Required for deployment.
include(qmlapplicationviewer/qmlapplicationviewer.pri)
qtcAddDeployment()

RESOURCES += \
    qmlres.qrc

OTHER_FILES += \
    qml/MainForm.qml
离线XChinux

只看该作者 2楼 发表于: 2012-12-13
把mainForm改成MainForm.qml看看
二笔 openSUSE Vim N9 BB10 XChinux@163.com 网易博客 腾讯微博
承接C++/Qt、Qt UI界面、PHP及预算报销系统开发业务
离线libadingzi

只看该作者 3楼 发表于: 2012-12-13
viewer.setMainQmlFile(QString(":/qml/mainForm"));
viewer.setMainQmlFile(QString(":/qml/qml/MainForm.qml"));
viewer.setMainQmlFile(QString(":/qml/MainForm.qml"));
上面三种方式都试过,都不行
离线XChinux

只看该作者 4楼 发表于: 2012-12-13
把prefix改成/,把alias去掉。
二笔 openSUSE Vim N9 BB10 XChinux@163.com 网易博客 腾讯微博
承接C++/Qt、Qt UI界面、PHP及预算报销系统开发业务
离线libadingzi

只看该作者 5楼 发表于: 2012-12-13
都试过了,还是一样的错误,我下载QT4.8.4的MinGW版本试试,估计真的跟编译器相关
离线libadingzi

只看该作者 6楼 发表于: 2012-12-14
昨晚试了QT 4.8.4,很不幸,结果与QT 5.0 RC一样,纳闷。在公司试了下,效果也一样,这难道不成是QT 5.0 RC的一个BUG?
快速回复
限100 字节
 
上一个 下一个