Removing dotted border without setting NoFocus in Windows PyQt

前端 未结 5 1659
猫巷女王i
猫巷女王i 2021-02-04 02:18

There are a few questions on SO about this, all of which seem to say that the only way to remove the dotted border is to set the focusPolicy on widget/item in question to NoFocu

5条回答
  •  清酒与你
    2021-02-04 02:50

    You can do this with PyQt5:

    class Style(QProxyStyle):
        def drawPrimitive(self, element, option, painter, widget):
            if element == QStyle.PE_FrameFocusRect:
                return
            super().drawPrimitive(element, option, painter, widget)
    
    app.setStyle(Style())
    

提交回复
热议问题