Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/python-3.x/15.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 如何在QlineEdit中更改单个字符串的颜色_Python_Python 3.x_Colors_Pyqt5_Qlineedit - Fatal编程技术网

Python 如何在QlineEdit中更改单个字符串的颜色

Python 如何在QlineEdit中更改单个字符串的颜色,python,python-3.x,colors,pyqt5,qlineedit,Python,Python 3.x,Colors,Pyqt5,Qlineedit,我正在使用计算器,当我点击“+”按钮时,我希望“+”是绿色而不是白色,而不改变数字的白色 这是按钮“+”的代码: 为了使我的问题简单明了,我希望输出如下: 您可以尝试使用 splus.setStyleSheet("QLineEdit { background: rgb(xxx,xxx,xxx); selection- background-color: rgb(xxx,xxx,xxx); }") 将由QLineEdit的clicked事件激发为: splus.cli

我正在使用计算器,当我点击“+”按钮时,我希望“+”是绿色而不是白色,而不改变数字的白色

这是按钮“+”的代码:

为了使我的问题简单明了,我希望输出如下:


您可以尝试使用

    splus.setStyleSheet("QLineEdit { background: rgb(xxx,xxx,xxx); selection- 
    background-color: rgb(xxx,xxx,xxx); }")
将由QLineEdit的clicked事件激发为:

    splus.clicked.connect(self.toggleColors) 

希望它对您有用。

您可以尝试使用

    splus.setStyleSheet("QLineEdit { background: rgb(xxx,xxx,xxx); selection- 
    background-color: rgb(xxx,xxx,xxx); }")
将由QLineEdit的clicked事件激发为:

    splus.clicked.connect(self.toggleColors) 
希望对你有用