Hey folk,
Here is the thing
- I’m working with maya 2017 update 3 and I’ve created a docked QT window via MayaQWidgetDockableMixin.
- I’ve overriden a QWidget class with it’s own sizes, color, events etc. (I’ve changed it’s color with self.setPalette() method)
- I’ve added the widget to the Main Docked Window.
The problem is:
- When I override enterEvent and leaveEvent where I set another cursor and background changes - they have no effect. If I just print smth like event.type() or whatever - it works. I don’t know why it happens. I’ve already tested it out on my Linux OS with the same Maya 2017 Upd3 - the same issue. It’s so stupid problem and really makes me crazy.
Here is my source code, if you have the same version of Maya - try it and tell me how it worked, I have Maya2017 without any updates on my mac and this code works perfect, I’m expecting it happens because of some glitches in update 3 or may be I’m wrong
`from maya.app.general.mayaMixin import MayaQWidgetDockableMixin
from PySide2 import QtWidgets, QtGui, QtCore
import maya.cmds as cmds
def deleteControl(control):
if cmds.workspaceControl(control, q=True, exists=True):
cmds.workspaceControl(control, e=True, close=True)
cmds.deleteUI(control, control=True)
class MyWid(QtWidgets.QWidget):
def __init__(self, parent = None):
super(MyWid, self).__init__(parent)
self.setMinimumSize(50,50)
self.setMaximumSize(50,50)
self.bg_color = 49
self.setAutoFillBackground(True)
self.p = self.palette()
self.p.setColor(self.backgroundRole(), QtGui.QColor(self.bg_color,self.bg_color,self.bg_color))
self.setPalette(self.p)
def enterEvent(self, event):
self.setCursor(QtCore.Qt.PointingHandCursor)
self.p.setColor(self.backgroundRole(), QtGui.QColor(self.bg_color+70,self.bg_color,self.bg_color))
self.setPalette(self.p)
return QtWidgets.QWidget.enterEvent(self, event)
def leaveEvent(self, event):
self.setCursor(QtCore.Qt.ArrowCursor)
self.p.setColor(self.backgroundRole(), QtGui.QColor(self.bg_color,self.bg_color,self.bg_color))
self.setPalette(self.p)
return QtWidgets.QWidget.leaveEvent(self, event)
def mouseMoveEvent(self, event):
self.setCursor(QtCore.Qt.PointingHandCursor)
return QtWidgets.QWidget.mouseMoveEvent(self, event)
class DialogWidget(MayaQWidgetDockableMixin, QtWidgets.QDialog):
def __init__(self, parent=None):
super(DialogWidget, self).__init__(parent=parent)
self.setObjectName('test_asadsgfasf')
self.setWindowTitle('test_asadsgfasf')
self.setLayout(self.createLayout())
def createLayout(self):
self.main_layout = QtWidgets.QVBoxLayout()
self.button = QtWidgets.QPushButton("ASDASDD")
self.test = MyWid()
self.main_layout.addWidget(self.button)
self.main_layout.addWidget(self.test)
return self.main_layout
def main():
deleteControl("test_asadsgfasfWorkspaceControl")
dialogValidatorX = DialogWidget()
dialogValidatorX.show(dockable=True, area='right', allowedArea = "right", floating=False)
cmds.workspaceControl("test_asadsgfasfWorkspaceControl", e=True, ttc=["AttributeEditor", 0], wp="preferred", mw=420)
dialogValidatorX.raise_()`