一、最近主要集中解决一个窗口层叠问题:
(1)将控件/临时/放最上层:
widget.activateWindow():一定要先指定活动操作的控件,不然程序不知道操作哪个对像
widget.raise_()
用raise():由于在python3中 raise 是一个关键字,所以在PyQt5中这个方法的名字为 raise_,即widget.raise_(),但必须先指定需要的窗口为activateWindow
>>> widget3.activateWindow()
>>> widget3.raise_()
至此完美解决界面显示的问题
(2)将控件一直放于最上层:
widget2.setWindowFlags(Qt.WindowStaysOnTopHint)
功能除非关闭,会一直在最上方
二、最近主要集中解决TableView相关内容,用红色显示问题(包括背景):
窗口与背景颜色
setFont
item.setFont(QFont(‘Times’),14,QFont.Black))
setForeground
item.setForeground(QBrush(QColor(255,255,0))
setBackground
item.setBackground(QBrush(QColor(0,0,255))
setForeground
item.setForeground(QBrush(QColor(255,255,255))
255,255,255白色;255,255,0黄色;255,0,0红色