小编Mys*_*rce的帖子

改变QCompleter的风格?

我尝试在 QCompleter 弹出窗口中的特定 QLineEdit 中应用样式表。

在 QtDesigner 中尝试:

在此输入图像描述

代码:

QLineEdit#lineEdit::popup{
background:red;
}
Run Code Online (Sandbox Code Playgroud)

但它不起作用

我正在寻找的是改变字母的颜色,背景颜色和出现在框中的字母与建议的对齐方式

也尝试一下 QtDesigner

QAbstractItemView {}
QAbstractItemView :: item {}
Run Code Online (Sandbox Code Playgroud)

更改 QLineEdit 中显示的建议列表的视觉属性,但它们不起作用

在我的代码中尝试:

from PyQt5.QtWidgets import QMainWindow,QApplication, QCompleter
from PyQt5 import QtCore
from PyQt5 import uic



class Pricnipal(QMainWindow):
    def __init__(self):
        QMainWindow.__init__(self)
        uic.loadUi("uno.ui",self)

        completer = QCompleter()

        self.lineEdit.setCompleter(completer)
        model = QtCore.QStringListModel()
        completer.setModel(model)
        self.get_data(model)
    def get_data(self,model):
        model.setStringList(["uno","dos","tres","cuatro","este es mi nombre"])


app  = QApplication([])
p = Pricnipal()
p.show()
app.exec_()
Run Code Online (Sandbox Code Playgroud)

python pyqt qcompleter qtstylesheets pyqt5

2
推荐指数
1
解决办法
1678
查看次数

标签 统计

pyqt ×1

pyqt5 ×1

python ×1

qcompleter ×1

qtstylesheets ×1