PyQt5——QSS

PyQt5——QSS,第1张

QSS全称为Qt StyleSheet,是用来控制QT控件的样式表。其和Web前段开发中的CSS样式表类似。

最小化按钮设置:

1、边缘圆角

2、鼠标悬浮变色(换图片)

下拉列表的设置:

1、边缘圆角

2、右边按钮样式自定义

进度条设置:

1、进度条颜色

2、进度条 

设置滚动栏和生成城市按钮:

1、取消显示横纵滚动条

2、自动生成城市列表

'''

【简介】

PyQT5的表格中支持右键菜单例子

'''

import sys

from PyQt5.QtWidgets import (QMenu, QPushButton, QWidget, QTableWidget, QHBoxLayout, QApplication, QTableWidgetItem,

QHeaderView)

from PyQt5.QtCore import QObject, Qt

class Table(QWidget):

if name == ' main ':

app = QApplication(sys.argv)

example = Table()

example.show()

sys.exit(app.exec_())

c++下面是将数据读取出来,然后添加到qlistview中,这样可以列表型显示。然后把这个列表绘制到qlineedit下面。

在这种情况下,您不需要QCompleter。请尝试以下示例:

from PyQt5 import QtCore, QtGui, QtWidgetsclass Window(QtWidgets.QMainWindow):

def __init__(self, cList):

super().__init__()

self.cList = cList

self.lineEdit_1 = QtWidgets.QLineEdit()

self.lineEdit_2 = QtWidgets.QLineEdit()

layoutH = QtWidgets.QHBoxLayout()

layoutH.addWidget(self.lineEdit_1)

layoutH.addWidget(self.lineEdit_2)#completer = QtWidgets.QCompleter(self)#model = QtCore.QStringListModel()#completer.setModel(model)

self.comboBox_4 = QtWidgets.QComboBox()#self.comboBox_4.setCompleter(completer)

self.comboBox_4.addItems(sorted(cList.keys()))

self.comboBox_4.activated[str].connect(self.onActivatedText)

layoutV = QtWidgets.QVBoxLayout()

layoutV.addLayout(layoutH)

layoutV.addWidget(self.comboBox_4)

centralWidget = QtWidgets.QWidget()

centralWidget.setLayout(layoutV)

self.setCentralWidget(centralWidget)

@QtCore.pyqtSlot(str)

def onActivatedText(self, text):

self.lineEdit_1.setText(self.cList[text][0])

self.lineEdit_2.setText(self.cList[text][1])autocompleteList2 = {

'James-1': ['[email protected]', '410-111-1111'],

'James-2': ['[email protected]', '410-222-2222'],

'James-3': ['[email protected]', '410-333-3333'],}if __name__ == '__main__':

import sys

app = QtWidgets.QApplication(sys.argv)

w = Window(autocompleteList2)

w.show()

sys.exit(app.exec_())


欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/bake/11730132.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-05-18
下一篇 2023-05-18

发表评论

登录后才能评论

评论列表(0条)

保存