Qt如何去掉按钮等控件的虚线框(焦点框)(三种办法)

方法1:可以通过代码ui->pushButton->setFocusPolicy(Qt::NoFocus)或在Qt Creator的属性列表中设置。

方法2:如果在嵌入式设备中需要通过按键切换控件,最简单的方法就是通过控件的focus来实现,就不能使用方法1          了。此时可以通过qss样式表来去掉虚线框,代码如下所示。

[cpp] view plain copy
 
 在CODE上查看代码片派生到我的代码片
  1. ui->pushButton->setStyleSheet("outline: none");  


方法3:也是通过qss样式表来实现,代码如下所示。

[cpp] view plain copy
 
 在CODE上查看代码片派生到我的代码片
  1. ui->pushButton->setStyleSheet("padding: -1");  

参考链接:http://blog.csdn.net/jwybobo2007/article/details/7520081

http://blog.csdn.net/caoshangpa/article/details/51771696

原文地址:https://www.cnblogs.com/findumars/p/5836143.html