【问题标题】:Qt Creator not showing border image of Qlabel after migration from Visual Studio 2015从 Visual Studio 2015 迁移后,Qt Creator 未显示 Qlabel 的边框图像
【发布时间】:2017-05-16 12:34:09
【问题描述】:

所以我在 Qt 中制作 GUI,我的问题是 Qt 似乎忽略了 Qlabel 的边框图像。这是我的cards.qrc

<RCC>
    <qresource prefix="/">
        <file>----.bmp</file>
    </qresource>
</RCC>

代码如下:

ClickableLabel::ClickableLabel(const QString& text) : QLabel()
{
    this->setStyleSheet("QLabel { border-image : url(----.bmp); color : red; }");
}

我在 .pro 文件中添加了这一行:

RESOURCES += cards.qrc

当我在 Visual Studio 中有这段代码时,一切都运行良好,在 Qt Creator 中没有,它似乎忽略了这个图像。有人可以帮我解决这个问题吗?

【问题讨论】:

    标签: c++ visual-studio qt qlabel


    【解决方案1】:

    您在资源文件的路径中遗漏了“:”符号。 像这样改变你的样式表:

    this->setStyleSheet("QLabel { border-image : url(:/----.bmp); color : red; }");
    

    【讨论】:

      猜你喜欢
      • 2016-12-10
      • 1970-01-01
      • 2017-06-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多