import sys
from PySide6.QtWidgets import (
QApplication,
QWidget,
QVBoxLayout,
QGridLayout,
QGroupBox
)
class EmailBox(QWidget):
def __init__(self) -> None:
super().__init__()
self._emailbox_layout = QVBoxLayout()
self.setLayout(self._emailbox_layout)
self._emailbox_layout.addWidget(self._Draw())
def _Draw(self):
self._gb = QGroupBox()
self._layout = QGridLayout()
self._layout.addWidget(self._gb)
if (the cursor is hovering over the groupbox) :
self._hovered
else:
self._not_hovered: ...
return self._gb
def _hovered(self):
print(1)
def _not_hovered(self):
print(2)
def main():
app: QApplication = QApplication(sys.argv)
ex = EmailBox()
ex.show()
sys.exit(app.exec())
if __name__ == "__main__":
main()
What I want is to implement into the code here above a check that checks whether the cursor is hovered over a group box, here the self._gb group box, and then do some logic defined by the _hovered() function. If the cursor leaves the group box, or is simply not hovered over it, then implement the logic of _not_hovered(). This is order to change some QPushButtons that would be put into the group box. Uncovered, there are no buttons, then when it is hovered, it add three buttons to the group box to the right. I know how to implement this, I just don't know the proper way to implement a way to see if the group box is hovered or not...