简体   繁体   English

Qt样式表和“一个论点”问题

[英]Qt Stylesheets and the “one argument” issue

I usually find a workaround for this, however it is getting on my nerves lately and I cannot find any information regarding it anywhere on the internet. 我通常会为此找到一种解决方法,但是最近它变得很烦人,我无法在Internet上的任何地方找到任何有关它的信息。

Right, I want to change the property of a progress bar I have in Qt and have set the initial values in the form designer. 正确,我想更改我在Qt中拥有的进度条的属性,并在表单设计器中设置了初始值。

This is what I have in my initial (and working) style sheet configuration: 这是我最初(和正在使用的)样式表配置中的内容:

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

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

(NOTE: Bare in mind that I have done it in the Form Designer, which is the inbuilt drag and drop graphical designer for Qt) (注意:请记住,我已经在Form Designer中完成了该工作,它是Qt内置的拖放图形设计器)

However, I want to change it programmatically within the code by doing this: 但是,我想通过以下方式在代码中以编程方式更改它:

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

According to the documentation for style sheets , it should be working with not problem whatsoever, but I get the following non-nonsensical error: 根据样式表文档 ,它应该没有任何问题,但是我收到以下非荒谬的错误:

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

Any ideas on what might be causing this? 关于什么可能导致此的任何想法?

您正在寻找的功能是setStyleSheet

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM