Using designMode as constructor parameter is not very nice.
If you create a widget by composition and use it with QtDesigner (*) , the children of the widget will not be in designerMode and it will create a mess.
(*) for example by importing a .ui file. But in pure python code, providing designerMode everywhere it is needed is also a mess.
One way to fix that, the one i use with the help of Tiago is to check the modules:
designMode = 'PyQt4.QtDesigner' in sys.modules
It does not support all the cases, but it can be improved
Another way is to inject the context to the class when we create the QtDesignerPlugin
klass.QTDESIGNER_CONTEXT = True
And using something like that on the class:
designMode = hasattr(self, "QTDESIGNER_CONTEXT")
I like the idea! I prefer something like the first option.
The weak point is if somebody does this kind of program:
I propose here what I believe is a safer implementation:
I think we could have in taurus.qt.QtGui an API to check/set if in QtDesigner:
When QtDesigner starts, it imports taurus.qt.qtdesigner.tauruspluginplugin.
The taurus.qt.qtdesigner.tauruspluginplugin could set the designer mode to True:
The widgets could check if they are in QtDesigner if needed by doing:
I like that!