这个问题有救吗? 我需要在类里边更改对象的数值,但是这个对象又是用这个类创建的。
def button_python(self):
self.python = <strong><u>Button_python</u></strong>(self)
self.python.setWindowFlag(QtCore.Qt.FramelessWindowHint)
self.python.setMaximumSize(100, 137) # 限定最大尺寸
self.python.setMinimumSize(100, 100) # 限定最小尺寸
self.python.move(140, 33) # 按钮位置
self.python.setStyleSheet(
"Button_python{background:240,240,240;border-radius:3px;}Button_python:hover{background:160,160,160;}") # 160
self.label = QLabel(self.python)
self.label.setGeometry(3, 3, 94, 94)
self.label.setStyleSheet('QLabel{border:3px solid rgb(0,0,0);}')
ma_p = QPixmap('../Icon_file/python.jpg') # 标签加图片
self.label.setPixmap(ma_p) # 标签添加图片
self.label.setScaledContents(True)
self.labels = QLabel(self.python)
self.labels.move(4, 54)
self.labels.setFont(QFont('微软雅黑'))
self.labels.setStyleSheet('font-size:11px; color:white;') # red
self.labels.setText('Python\n结构简单\n明确定义的语法\n学习起来更加简单。')
self.labels.adjustSize()
self.labels.hide()
self.buupython = QPushButton(self.python)
self.buupython.move(60, 10)
self.buupython.resize(30, 24)
self.buupython.setToolTip('进入Python') # 当鼠标指向按钮时提示语
self.buupython.setIcon(QIcon('../Icon_file/deng.png'))
size1 = QSize(50, 24)
self.buupython.setIconSize(size1)
self.buupython.setStyleSheet(
"QPushButton{background:160,160,160;border-radius:5px;}QPushButton:hover{background:#D3D3D3;}")
self.buupython.hide()
class <strong><u>Button_python</u></strong>(QMdiSubWindow):
def __init__(self, parent=None):
super(Button_python, self).__init__(parent)
# other initializations...
def enterEvent(self, QEvent):
# here the code for mouse hover
print('鼠标停留')
<u><strong>当鼠标指向时在这里改变用这个类创建的对象的值。比如:</strong></u>
python.move(140, 23)
python.resize(100, 137)
label.setGeometry(3, 3, 54, 54)
labels.show()
buupython.show()