设置QPushButton不可点击
时间: 2024-04-07 12:33:20 浏览: 28
要设置QPushButton不可点击,你可以使用QPushButton的setEnabled()方法,并将其参数设置为False。以下是一个示例代码:
```python
button = QPushButton("Click me")
button.setEnabled(False)
```
这将禁用按钮,并使其无法点击。
相关问题
qtpushbutton设置不可点击
您可以使用QPushButton的setEnabled()函数来设置按钮是否可点击。如果将其设置为false,则按钮将变为灰色,不可点击。例如:
QPushButton *button = new QPushButton("按钮", this);
button->setEnabled(false); // 设置按钮不可点击
QTC++怎么设置按钮不可点击
你可以使用QPushButton类的setEnabled(bool)函数来设置按钮是否可用。如果想让按钮不可点击,可以将参数设置为false,例如:
```
QPushButton *button = new QPushButton("Click me");
button->setEnabled(false); // 设置按钮不可用
```
这样,按钮就会变成灰色,无法点击。如果需要再次启用按钮,只需要将参数设置为true即可,例如:
```
button->setEnabled(true); // 设置按钮可用
```
相关推荐
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.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)