这个问题有救吗? 我需要在类里边更改对象的数值,但是这个对象又是用这个类创建的。
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()
从代码上分析,问题应该不大,但实际运行中有什么问题呢?
您好,我是有问必答小助手,您的问题已经有小伙伴解答了,您看下是否解决,可以追评进行沟通哦~
如果有您比较满意的答案 / 帮您提供解决思路的答案,可以点击【采纳】按钮,给回答的小伙伴一些鼓励哦~~
ps:问答VIP仅需29元,即可享受5次/月 有问必答服务,了解详情>>>https://vip.csdn.net/askvip?utm_source=1146287632
非常感谢您使用有问必答服务,为了后续更快速的帮您解决问题,现诚邀您参与有问必答体验反馈。您的建议将会运用到我们的产品优化中,希望能得到您的支持与协助!
速戳参与调研>>>https://t.csdnimg.cn/Kf0y