Advertisement
Guest User

Untitled

a guest
Feb 23rd, 2019
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.54 KB | None | 0 0
  1. class window_b(QtGui.QDialog):
  2. def __init__(self,parent=None):
  3. super(window_b, self).__init__(parent)
  4. window_a.setEnabled(False)
  5. self.ui = Ui_Form_window_b()
  6. self.ui.setupUi(self)
  7. self.setFocusPolicy(QtCore.Qt.StrongFocus)
  8. def mouseMoveEvent (self,event):
  9. source= self.sender()
  10. #print source.name()
  11. # The action I want to do when the mouse is over the button:
  12. source.setStyleSheet("background-color:#66c0ff;border-radiuβ€Œβ€‹s: 5px;")
  13.  
  14. print source.name()
  15. AttributeError: 'NoneType' object has no attribute 'name'
  16.  
  17. class window_b(QtGui.QDialog):
  18. def __init__(self,parent=None):
  19. super(window_b, self).__init__(parent)
  20. window_a.setEnabled(False)
  21. self.ui = Ui_Form_window_b()
  22. self.ui.setupUi(self)
  23. self.setFocusPolicy(QtCore.Qt.StrongFocus)
  24.  
  25. # Get all the buttons (you probably don't want all of them)
  26. buttons = self.findChildren(QtGui.QAbstractButton)
  27. for button in buttons:
  28. button.installEventFilter(self)
  29.  
  30. def eventFilter(self, obj, event):
  31. if event.type() == QtCore.QEvent.Enter:
  32. print("mouse entered %s" % obj.objectName())
  33. elif event.type() == QtCore.QEvent.Leave:
  34. print("mouse leaved %s" % obj.objectName())
  35. return super(window_b, self).eventFilter(obj, event)
  36.  
  37. QPushButton {
  38. border: 1px solid black;
  39. padding: 5px;
  40. }
  41. QPushButton:hover {
  42. border: 1px solid black;
  43. border-radius: 5px;
  44. background-color:#66c0ff;
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement