Q: How to add the hover state to this button I have (as an image)? I need 
it to have the "hand icon" when hovering and also some sort of overlay like 
a darkening/lighting effect. Is it possible with my current code? I am 
using pyside/qt inside a DCC application, in this case Autodesk Maya 2022. 
Thank you.

from PySide2.QtWidgets import QApplication, QPushButton
from PySide2.QtGui import QPixmap, QIcon
from PySide2.QtCore import QSize

def clicked():
    print("Button clicked!")

window_wid = QtWidgets.QWidget()
vlayout_wid = QtWidgets.QVBoxLayout()


# Set Push Button
button = QPushButton()

button.setMaximumSize(200,100)

vlayout_wid.addWidget(button)

# Set image in Push Button
pixmap = QPixmap("my_image.jpg")
button_icon = QIcon(pixmap)
button.setIcon(button_icon)
button.setIconSize(QSize(200,100))

#button.show()
button.clicked.connect(clicked)

window_wid.setLayout(vlayout_wid)
window_wid.show()

[image: qt.png]

-- 
You received this message because you are subscribed to the Google Groups 
"Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/python_inside_maya/28a6b738-6028-4504-b057-6c526bc37da9n%40googlegroups.com.

Reply via email to