G:\hq\QT\day5\HomeWork\dialog.cpp:9: error: no matching function for call to 'QPushButton::styleSheet(const char [19])' ui->pushButton->styleSheet("border-radius:8px;"); ^
时间: 2024-02-14 11:16:09 浏览: 27
这个错误的原因是QPushButton类并没有styleSheet()函数以接受一个char类型的参数。正确的做法是使用setStyleSheet()函数,并将参数作为QString类型传递。
例如,可以这样修改代码:
```cpp
ui->pushButton->setStyleSheet("border-radius:8px;");
```
相关问题
dialog.cpp:129:21: error: call to non-static member function without an object argument
这个错误通常是因为你尝试在一个非静态成员函数中调用另一个非静态成员函数时,没有给这个函数提供一个对象参数。这个对象参数指的是调用这个成员函数的对象,也就是说,你需要先创建这个对象,然后使用这个对象来调用这个成员函数。
例如,在下面的代码中:
```
class MyClass {
public:
void func1() {
// do something
}
void func2() {
// call func1 without an object argument
func1();
}
};
int main() {
MyClass obj;
obj.func2();
return 0;
}
```
在 `func2` 中调用 `func1` 时,没有给 `func1` 提供一个对象参数。解决方法是要么将 `func1` 声明为静态成员函数,要么在调用 `func1` 时提供一个对象参数。例如:
```
class MyClass {
public:
void func1() {
// do something
}
void func2() {
// call func1 with an object argument
this->func1();
}
};
int main() {
MyClass obj;
obj.func2();
return 0;
}
```
在 `func2` 中使用 `this->func1()` 来调用 `func1` 并提供一个对象参数。
QObject::connect: No such slot Dialog::btnsClickedSlot(int) in ..\day6-1\dialog.cpp:14
这是一个连接信号与槽的错误,它指出在 Dialog 类中没有名为 btnsClickedSlot 的槽函数。可能的原因是:
1. 没有在 Dialog 类中声明 btnsClickedSlot 函数。
2. btnsClickedSlot 函数的参数列表与它在 connect 函数中的参数列表不匹配。
3. 拼写错误或大小写错误。
要解决这个错误,你需要检查 Dialog 类中是否声明了名为 btnsClickedSlot 的槽函数,并确保它的参数列表与 connect 函数中的参数列表完全匹配。你还需要检查拼写错误或大小写错误。
相关推荐
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![doc](https://img-home.csdnimg.cn/images/20210720083327.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)