Qt 样式表和 "one argument" 问题

Qt Stylesheets and the "one argument" issue

我通常会找到一个解决方法,但是最近它让我很不安,我在互联网上的任何地方都找不到任何关于它的信息。

好的,我想改变我在 Qt 中的进度条的 属性,并在表单设计器中设置了初始值。

这是我的初始(和工作)风格 sheet 配置:

QProgressBar {
    border: 2px solid grey;
    border-radius: 7px;
}

QProgressBar::chunk {
    background-color: #05B8CC;
    width: 20px;
}

(注意:请记住,我是在 Form Designer 中完成的,它是 Qt 的内置拖放图形设计器)

但是,我想通过以下方式在代码中以编程方式更改它:

ui->progressBar->styleSheet("QProgressBar::chunk { background-color: #05B8CC; width: 20px;}"); 

根据 documentation for style sheets,它应该没有任何问题,但我收到以下非无意义的错误:

D:\Qt Projects\test\mainwindow.cpp:165: error: C2660: 'QWidget::styleSheet' : function does not take 1 arguments

关于可能导致此问题的任何想法?

您要查找的函数是setStyleSheet