Package moul :: Package qt :: Module utils :: Class QNamespaceContainer
[hide private]
[frames] | no frames]

Class QNamespaceContainer



      object --+        
               |        
     sip.wrapper --+    
                   |    
PyQt4.QtCore.QObject --+
                       |
                      QNamespaceContainer
Known Subclasses:
wdysini.IniFileContainer, localization.LocalizationContainer

Base class to assemble methods and logic in its own class.

Slot methods (on_method_event()) are automatically connected to widgets of the parent. If the methods takes an argument you *must* apply a @pyqtSignature() decorator!

connect(), disconnect(), emit() and attribute access are forwarded to the parent class (like Zope2 implicit acquisition wrapper) but you *must* use self.context instead self as argument.
>>> class MyStuff(QNamespaceContainer):
...     def initialize(self): 
...         self.connect(self.context, SIGNAL("foo()"), bar)
...
...     @pyqtSignature("int")
...     def on_button_clicked(self, boolean):
Now add the container to your class >>> class MainWindow(QtCore.QObject): ... def __init__(self, parent=None): ... QtCore.QObject.__init__(self, parent=None) ... self.qcMystuff = MyStuff(parent)


Warning: If you are creating new QObject based instances you should bind them to self.context and *not* to self. This is especially true for QWidget based objects.

Instance Methods [hide private]
  __init__(self, parent)
Constructor
  connect(self, *args)
Shortcut for self.parent().connect(*args)
  disconnect(self, *args)
Shortcut for self.parent().disconnect(*args)
  emit(self, *args)
Shortcut for self.parent().emit(*args)
  __getattr__(self, name, default=_marker)
Get attributes form parent.
  initialize(self)
Initialize method

Inherited from PyQt4.QtCore.QObject: blockSignals, childEvent, children, connectNotify, customEvent, deleteLater, disconnectNotify, dumpObjectInfo, dumpObjectTree, dynamicPropertyNames, event, eventFilter, findChild, findChildren, inherits, installEventFilter, isWidgetType, killTimer, metaObject, moveToThread, objectName, parent, property, receivers, removeEventFilter, sender, setObjectName, setParent, setProperty, signalsBlocked, startTimer, thread, timerEvent, tr, trUtf8

Inherited from sip.wrapper: __delattr__, __getattribute__, __new__, __setattr__

Inherited from object: __hash__, __repr__, __str__


Class Variables [hide private]

Inherited from PyQt4.QtCore.QObject: __reduce__, __reduce_ex__


Properties [hide private]
  context
Shortcut for self.parent()

Inherited from object: __class__


Method Details [hide private]

__init__(self, parent)
(Constructor)

 

Constructor

Calls initialize() and auto connects slot methods with parent's widgets.
Parameters:
  • parent (a QObject based instance) - the Qt parent object
Overrides: sip.wrapper.__init__

connect(self, *args)

 
Shortcut for self.parent().connect(*args)
Overrides: PyQt4.QtCore.QObject.connect

disconnect(self, *args)

 
Shortcut for self.parent().disconnect(*args)
Overrides: PyQt4.QtCore.QObject.disconnect

emit(self, *args)

 
Shortcut for self.parent().emit(*args)
Overrides: PyQt4.QtCore.QObject.emit

__getattr__(self, name, default=_marker)
(Qualification operator)

 

Get attributes form parent.

Works similar to Zope 2's Implicit Acquisition wrapper.

initialize(self)

 

Initialize method

Must be implement in the subclass

Property Details [hide private]

context

Shortcut for self.parent()
Get Method:
unreachable.context(self) - Shortcut for self.parent()
Set Method:
None                                                                  
- helper for pickle
Delete Method:
None                                                                  
- helper for pickle