【发布时间】:2014-02-23 20:26:09
【问题描述】:
更新: 我从 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>
原文:
我是 Qt 5.2.1 的新手(一般来说),我正在使用 Qt Creator 构建桌面应用程序。我正在尝试使用外部样式表,所以我在网上做了一些阅读,找到了一个很好的免费样式表,并阅读了如何将它作为资源加载到我的代码中。我的问题是资源文件,我在阅读时创建了一个资源,并尝试在我的主函数中打开它以应用样式表。 Qt 似乎不认为该文件存在,Qt Creator 肯定会识别资源中所有这些文件的正确放置和存在,但 file.open 每次都返回 false。以下是一些截图:
【问题讨论】:
-
file.errorString() 在 else 分支中返回什么?添加 .pro 文件和 .qrc 文件的源代码(而不是屏幕截图)。
-
我想最初我是想确保我第一次没有错过任何重要的事情,但得到了它。
-
@ChristopherBrown:你重新运行 qmake 了吗? file.errorString() 按照 Frank 的要求说了什么?
-
您可以尝试删除所有生成的构建文件,包括make文件正在重建您的项目。
-
我在更新后添加了errorString。 @Nejat 会试试这个。
标签: c++ qt qt-creator