QtGui closeEvent
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Be nice to others! Respect the FreeCAD code of conduct!
QtGui closeEvent
Hi,
I'm doing a a macro with QtGui interface
I would need to trigger an action on closing the main QtGui windows
starting from the QtGui example
http://www.freecadweb.org/wiki/index.ph ... r_Examples
More Than 2 Buttons
I would need to trigger a message box on closing the main Qt windows (e.g. a warning message before closing it)
thank you
Maurice
I'm doing a a macro with QtGui interface
I would need to trigger an action on closing the main QtGui windows
starting from the QtGui example
http://www.freecadweb.org/wiki/index.ph ... r_Examples
More Than 2 Buttons
I would need to trigger a message box on closing the main Qt windows (e.g. a warning message before closing it)
thank you
Maurice
Re: QtGui closeEvent
Code: Select all
from PySide import QtGui
class MyWindow(QtGui.QWidget):
def closeEvent(self, e):
res = QtGui.QMessageBox.question(None,"Close","Do you want to close the window?",QtGui.QMessageBox.Yes|QtGui.QMessageBox.No)
if res is QtGui.QMessageBox.No:
e.ignore()
m=MyWindow()
m.show()
Re: QtGui closeEvent
@wmayer
thanks a lot ... that was exactly I was looking for...
just an other question... is there a way to check if an other instance of the same QTGui window is running, so to avoid to double exec the widgets?
Maurice
thanks a lot ... that was exactly I was looking for...
just an other question... is there a way to check if an other instance of the same QTGui window is running, so to avoid to double exec the widgets?
Maurice
Re: QtGui closeEvent
In order to control this you have to implement the singleton pattern: http://python-3-patterns-idioms-test.re ... leton.htmljust an other question... is there a way to check if an other instance of the same QTGui window is running, so to avoid to double exec the widgets?
Re: QtGui closeEvent
thanx again!
very helpful forum and people!
Maurice
very helpful forum and people!
Maurice
Re: QtGui closeEvent
@wmayer
I tried singletone and it works if I launch my fuction e.g. twice in the same macro...
but my target was to avoid the possibility to execute the same macro invoked from e.g. FreeCAD toolbar...
thanks
Maurice
I tried singletone and it works if I launch my fuction e.g. twice in the same macro...
but my target was to avoid the possibility to execute the same macro invoked from e.g. FreeCAD toolbar...
thanks
Maurice
Re: QtGui closeEvent
Don't quite understand what you want to achieve.but my target was to avoid the possibility to execute the same macro invoked from e.g. FreeCAD toolbar...
Re: QtGui closeEvent
hi @wmayer,
e.g. I have configured in the tool bar a button for calling a QtGui macro e.g. Macro Clone Convert
http://www.freecadweb.org/wiki/index.ph ... oneConvert
I would like to avoid that the action to click on that macro button twice, will open two QtGui windows of the same macro
thanks
e.g. I have configured in the tool bar a button for calling a QtGui macro e.g. Macro Clone Convert
http://www.freecadweb.org/wiki/index.ph ... oneConvert
I would like to avoid that the action to click on that macro button twice, will open two QtGui windows of the same macro
thanks