Qt无法识别.qrc中文件的存在

时间:2014-02-23 20:26:10

标签: c++ qt qt-creator

更新 我从file.errorString得到以下内容:“未知错误”......很有帮助。我的.pro文件来源:

QT       += core gui

greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

TARGET = RegionsBuilder2
TEMPLATE = app


SOURCES += main.cpp\
        mainwindow.cpp

HEADERS  += mainwindow.h

FORMS    += mainwindow.ui

RESOURCES += style.qrc

我的.qrc文件来源:

<RCC>
    <qresource prefix="/qss_icons">
        <file>rc/up_arrow_disabled.png</file>
        <file>rc/Hmovetoolbar.png</file>
        <file>rc/stylesheet-branch-end.png</file>
        <file>rc/branch_closed-on.png</file>
        <file>rc/stylesheet-vline.png</file>
        <file>rc/branch_closed.png</file>
        <file>rc/branch_open-on.png</file>
        <file>rc/transparent.png</file>
        <file>rc/right_arrow_disabled.png</file>
        <file>rc/sizegrip.png</file>
        <file>rc/close.png</file>
        <file>rc/down_arrow.png</file>
        <file>rc/Vmovetoolbar.png</file>
        <file>rc/left_arrow.png</file>
        <file>rc/stylesheet-branch-more.png</file>
        <file>rc/up_arrow.png</file>
        <file>rc/right_arrow.png</file>
        <file>rc/left_arrow_disabled.png</file>
        <file>rc/Hsepartoolbar.png</file>
        <file>rc/checkbox.png</file>
        <file>rc/branch_open.png</file>
        <file>rc/Vsepartoolbar.png</file>
        <file>rc/down_arrow_disabled.png</file>
        <file>rc/undock.png</file>
    </qresource>
    <qresource prefix="/qdarkstyle">
        <file>style.qss</file>
    </qresource>
    <qresource prefix="/misc">
        <file>cman.png</file>
    </qresource>
</RCC>

ORIGINAL:

我是Qt 5.2.1(一般情况下)的新手,我正在使用Qt Creator构建桌面应用程序。我正在尝试使用外部样式表,所以我在网上做了一些阅读,找到了一个很好的免费样式表,并阅读了如何将其作为资源加载到我的代码中。我的问题是资源文件,我创建了一个资源,因为我读了我应该并尝试在我的main函数中打开它来应用样式表。 Qt似乎认为该文件不存在,Qt Creator肯定会识别资源中所有这些文件的正确放置和存在,但file.open每次都返回false。以下是一些镜头:

screen1

screen2

screen3

screen4

1 个答案:

答案 0 :(得分:0)

解决!所需要的就是快速打电话给“干净”。谢谢@Nejat的提示!