2014-02-23 36 views
0

更新: 我从file.errorString得到以下:“未知错误”...有帮助。另外我.pro文件来源:Qt不识别文件内存在.qrc

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构建桌面应用程序。我试图使用外部样式表,所以我在网上做了一些阅读,找到了一个很好的免费样式表,并阅读了如何将它作为资源加载到我的代码中。我的问题是与资源文件,我创建了一个资源,因为我读了我应该试图打开它在我的主函数来应用样式表。 Qt似乎并不认为该文件存在,Qt Creator当然可以识别资源中所有这些文件的正确位置和存在,但file.open每次都会返回false。下面是一些截图:

screen1

screen2

screen3

screen4

+0

什么是file.errorString()在else分支中返回?添加.pro文件和.qrc文件的源代码(而不是截图)。 –

+0

我认为最初我试图确保我没有错过任何重要的第一次,但明白了。 –

+0

@ChristopherBrown:你重新运行qmake吗? file.errorString()如Frank所要求的那样说什么? – lpapp

回答

0

解决了!所需要的只是一个“干净”的快速通话。感谢@Nejat提示!