-
Hi all,
In my element I am creating SBGWindow from QWidgets and I would like to catch their closing signal. Does any one of you know how to do it ?
I already tried to connect to the QWidget closing signal:
SAMSONWindow = SAMSON::addWidget(windowsVector[imageNumber], "RDKit SmilesConverter", SBGWindow::Lockable); QObject::connect(SAMSONWindow, SIGNAL(close()), this, SLOT(saveImage()));But it didn't work because SBGWindow doesn't have close() signal. I think it will be very useful to add it.
Thanks for your help !
Yassine -
If windowsVector[imageNumber] derives from SBGWindowWidget, you have two possibilities:
The first one is to override the SBGWindowWidget::hideEvent(QHideEvent* event) function:
void MyWidget::hideEvent(SBGWindowWidget::hideEvent(QHideEvent* event)) { // do something // call the hideEvent function of the parent class SBGWindowWidget::hideEvent(QHideEvent* event) }The second one is to connect to the shown() signal of the SBGWindowWidget class (hence your derived class):
QObject::connect(windowsVector[imageNumber], SIGNAL(shown(bool)), this, SLOT(saveImage(bool)));When the window is closed, shown(false) is emitted.
-
Actually yes, I didn't test it before but
hideEvent()is also called when the window is locked for the same reason as shown signal. Hmmm I thought it was possible to filter the eventevent->type() == QHideEvent::Hidebut it seems that locking the window and hiding it (meaning closing it) has the same event type. Is it possible to distinguish these two actions ?
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login