PySide PyQt 图标模糊

做了一个搜索条

参考:

(4条消息) Qt 之自定义搜索框_青春不老,奋斗不止!-CSDN博客_qt搜索框 

里面的第一种方法会出现图标模糊的情况,然后采用第二种方法成功解决!

这里有一个图标模糊的文章可以看一下:

Qt图标显示模糊原因及解决方法 (huyaohui.com)


 

self.line_edit = QLineEdit(self)
        self.line_edit.setFixedHeight(self.selectheight)
        self.line_edit.setAttribute(Qt.WA_InputMethodEnabled, False)#屏蔽输入法
        self.line_edit.setStyleSheet(u"background-color: rgb(33, 37, 43);\
                                     border-radius: 17px;")
        self.line_edit.setPlaceholderText(QCoreApplication.translate("MainWindow", u"搜索节点..", None))
        self.line_edit.returnPressed.connect(self.lineEdit_function)
        self.extention = CodeAC(self.line_edit)

self.selectbutton = QPushButton("",self)
        self.selectbutton.clicked.connect(self.selectNode)
        self.selectbutton.setCursor(QCursor(Qt.PointingHandCursor))
        self.selectbutton.setFixedSize(self.selectheight-4,self.selectheight-4)
        self.selectbutton.setStyleSheet("border: none;border-radius: 15px;")
        icon1 = QIcon()
        icon1.addFile(u":/icons/images/icons/cil-magnifying-glass.png", QSize(), QIcon.Normal, QIcon.Off)
        self.selectbutton.setIcon(icon1)
        self.select_hlayout = QHBoxLayout()
        self.select_hlayout.addStretch()
        self.select_hlayout.addWidget(self.selectbutton)
        self.select_hlayout.setSpacing(0)
        self.select_hlayout.setContentsMargins(0, 0, 2, 0)
        self.line_edit.setLayout(self.select_hlayout)
        #icon1 = QIcon()
        #icon1.addFile(u":/icons/images/icons/cil-magnifying-glass.png", QSize(50,50), QIcon.Normal, QIcon.Off)
        
        #new_action = QAction(self.line_edit)#创建对象
        #new_action.setIcon(icon1)  #设置图标
        #new_action.triggered.connect(self.selectNode)#点击信号
        #self.line_edit.addAction(new_action,QLineEdit.TrailingPosition)

文章中提到了QLineEditicon模糊,所以弃用QAction而是直接采用按钮的方式,这样就不会模糊了

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值