Qt4 样式表和焦点矩形 [英] Qt4 Stylesheets and Focus Rect

查看:68
本文介绍了Qt4 样式表和焦点矩形的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用样式表 :focus 伪状态来控制树视图的焦点状态的表示.使用下面的样式表效果很好,除了 Qt 系统仍然绘制它自己的焦点矩形.我如何要求 Qt 不绘制焦点矩形,同时仍然能够聚焦键盘输入的控件?

I would like to use a stylesheet :focus pseudo-state to control the representation of the Tree view's focus state. Using the following stylesheet works well, except that the Qt system still draws it's own focus rect. How do I ask Qt to not draw the focus rect, while still being able to focus the control for keyboard input?

QTreeView {
    background: #505050;
    border: 1px solid;
    border-radius: 10px;
}

QTreeView:focus { 
    border: 2px groove;
}

推荐答案

围绕 QTreeView 小部件本身的焦点矩形原来是一个 Mac 样式功能.这会关闭每个小部件:

The focus rect around the QTreeView widget itself turns out to be a Mac styling feature. This turns it off per widget:

tree.setAttribute(Qt.WA_MacShowFocusRect, 0)

这篇关于Qt4 样式表和焦点矩形的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆