aboutsummaryrefslogtreecommitdiffstats
path: root/doc
diff options
context:
space:
mode:
authorHugo Parente Lima <hugo.pl@gmail.com>2011-03-04 11:35:54 -0300
committerHugo Parente Lima <hugo.pl@gmail.com>2012-03-08 16:54:02 -0300
commit36fdd023e0d470bc3feb7472985f59eedc0a0857 (patch)
tree121940f63a0bf25ce66f4a5cb6eb3c7ebf56b7d1 /doc
parent632105b470da139380275c55d47076e4440f14ff (diff)
Removed Signal/Slot documentation content.
Diffstat (limited to 'doc')
-rw-r--r--doc/extras/PySide.QtCore.Signal.rst106
-rw-r--r--doc/extras/PySide.QtCore.Slot.rst85
2 files changed, 1 insertions, 190 deletions
diff --git a/doc/extras/PySide.QtCore.Signal.rst b/doc/extras/PySide.QtCore.Signal.rst
index a0318d412..b4c4e3667 100644
--- a/doc/extras/PySide.QtCore.Signal.rst
+++ b/doc/extras/PySide.QtCore.Signal.rst
@@ -25,110 +25,6 @@ Detailed Description
PySide adopt PyQt's new signal and slot syntax as-is. The PySide implementation is functionally compatible with the PyQt 4.5 one, with the exceptions listed bellow.
- .. note:: Parts of the documentation bellow are from the `PyQt4 documentation <http://www.riverbankcomputing.co.uk/static/Docs/PyQt4/pyqt4ref.html#new-style-signal-and-slot-support>`_ public available on the internet Copyright (c) 2010 Riverbank Computing Limited just modified to fit the PySide implementation.
-
-
-Defining New Signals with QtCore.Signal()
------------------------------------------
-
- PySide automatically defines signals for all Qt's built-in signals. New signals can be defined as class attributes using the QtCore.Signal() factory.
-
- QtCore.Signal() takes a number of type arguments that corresponds to the signature of the signal. Each type may be a Python type object or a string that is the name of a C++ type. Alternatively each argument could be a sequence of type arguments. In this case each sequence defines the signature of a different signal overload. The first overload will be the default.
-
- QtCore.Signal() takes an optional name keyword argument that is the name of the signal. If it is omitted then the name of the class attribute is used.
-
- The following example shows the definition of a number of new signals:
-
- ::
-
- from PySide import QtCore
-
- class Foo(QtCore.QObject):
-
- # This defines a signal called 'closed' that takes no arguments.
- closed = QtCore.Signal()
-
- # This defines a signal called 'rangeChanged' that takes two
- # integer arguments.
- range_changed = QtCore.Signal(int, int, name='rangeChanged')
-
- # This defines a signal called 'valueChanged' that has two overloads,
- # one that takes an integer argument and one that takes a QString
- # argument.
- valueChanged = QtCore.Signal((int, ), (unicode, ))
-
- # The following will create exactly the same overloaded signal as
- # above and demonstrates the use of C++ type names instead of Python
- # type objects, and lists instead of tuples.
- valueChanged = QtCore.Signal(['int'], ['unicode'])
-
- New signals should only be defined in sub-classes of QObject.
-
- New signals defined in this way will be automatically added to the class's QMetaObject. This means that they will appear in Qt Designer and can be introspected using the QMetaObject API.
-
-Connecting, Disconnecting and Emitting Signals
-----------------------------------------------
-
- Signals are connected and disconnected to slots using the :meth:`Signal.connect` and :meth:`Signal.disconnect` methods of a bound signal and emitted using the :meth:`Signal.emit` method.
-
- The following code demonstrates the definition, connection and emit of a signal without arguments:
-
- ::
-
- from PySide import QtCore
-
- class Foo(QtCore.QObject):
- # Define a new signal called 'trigger' that has no arguments.
- trigger = QtCore.Signal()
-
- def connect_and_emit_trigger(self):
- # Connect the trigger signal to a slot.
- self.trigger.connect(self.handle_trigger)
-
- # Emit the signal.
- self.trigger.emit()
-
- def handle_trigger(self):
- # Show that the slot has been called.
- print "trigger signal received"
-
- The following code demonstrates the connection of overloaded signals:
-
- ::
-
- from PySide import QtGui
-
- class Bar(QtGui.QComboBox):
-
- def connect_activated(self):
- # Avoid using default overloads, they are not safe and can change in the future.
- self.activated.connect(self.handle_int)
-
- # For non-default overloads we have to specify which we want to
- # connect. In this case the one with the single string argument.
- # (Note that we could also explicitly specify the default if we
- # wanted to.)
- self.activated[str].connect(self.handle_string)
-
- def handle_int(self, index):
- print "activated signal passed integer", index
-
- def handle_string(self, text):
- print "activated signal passed string", text
-
-Connecting Signals Using Keyword Arguments
-------------------------------------------
-
- It is also possible to connect signals by passing a slot as a keyword argument corresponding to the name of the signal when creating an object. For example the following three fragments are equivalent:
-
- ::
-
- act = QtGui.QAction("Action", self)
- act.triggered.connect(self.on_triggered)
-
- act = QtGui.QAction("Action", self, triggered=self.on_triggered)
-
-
.. method:: Signal.connect(receiver[, type=Qt.AutoConnection])
Create a connection between this signal and a `receiver`, the `receiver` can be a Python callable, a :class:`Slot` or a :class:`Signal`.
@@ -139,5 +35,5 @@ Connecting Signals Using Keyword Arguments
.. method:: Signal.emit(*args)
- `args` is the optional sequence of arguments to pass to any connected slots.
+ `args` is the arguments to pass to any connected slots, if any.
diff --git a/doc/extras/PySide.QtCore.Slot.rst b/doc/extras/PySide.QtCore.Slot.rst
index 27791d036..38654f988 100644
--- a/doc/extras/PySide.QtCore.Slot.rst
+++ b/doc/extras/PySide.QtCore.Slot.rst
@@ -8,88 +8,3 @@ Detailed Description
--------------------
PySide adopt PyQt's new signal and slot syntax as-is. The PySide implementation is functionally compatible with the PyQt 4.5 one, with the exceptions listed bellow.
-
- .. note:: Parts of the documentation bellow are from the `PyQt4 documentation <http://www.riverbankcomputing.co.uk/static/Docs/PyQt4/pyqt4ref.html#new-style-signal-and-slot-support>`_ public available on the internet Copyright (c) 2010 Riverbank Computing Limited just modified to fit the PySide implementation.
-
- Although PySide allows any Python callable to be used as a slot when connecting signals, it is sometimes necessary to explicitly mark a Python method as being a Qt slot and to provide a C++ signature for it. PySide provides the QtCore.Slot() function decorator to do this.
-
- All of the non-keyword arguments to the decorator are interpreted as the types of the corresponding C++ arguments. A type is either a Python type object or a string that specifies a C++ type. The decorator also takes two optional keywords arguments: name and result. name is the name of the slot that will be seen by C++. If ommitted the name of the Python method being decorated will be used. result is the type of the result and may also be a Python type object or a string that specifies a C++ type.
-
- For example:
-
- ::
-
- @QtCore.Slot()
- def foo(self):
- """ C++: void foo() """
-
- @QtCore.Slot(int, unicode)
- def foo(self, arg1, arg2):
- """ C++: void foo(int, QString) """
-
- @QtCore.Slot(int, name='bar')
- def foo(self, arg1):
- """ C++: void bar(int) """
-
- @QtCore.Slot(int, result=int)
- def foo(self, arg1):
- """ C++: int foo(int) """
-
- @QtCore.Slot(int, QtGui.QWidget)
- def foo(self, arg1):
- """ C++: int foo(int, QWidget*) """
-
- It is also possible to chain the decorators in order to define a Python method several times with different signatures.
-
- For example:
-
- ::
-
- @QtCore.Slot(int)
- @QtCore.Slot('QString')
- def valueChanged(self, value):
- """ Two slots will be defined in the QMetaObject. """
-
-Connecting Slots By Name
-------------------------
-
- PySide supports the QtCore.QMetaObject.connectSlotsByName() function that is most commonly used by pyside-uic generated Python code to automatically connect signals to slots that conform to a simple naming convention besides the QtCore.Slot decoration.
-
- For example the :class:`PySide.QtGui.QSpinBox` class has the following signals:
-
- ::
-
- void valueChanged(int i);
- void valueChanged(const QString& text);
-
- For example, if you were interested in the integer variant of the signal then your slot definition would look like the following:
-
- ::
-
- @QtCore.Slot(int)
- def on_spinbox_valueChanged(self, i):
- # i will be an integer.
- pass
-
- If you wanted to handle both variants of the signal, but with different Python methods, then your slot definitions might look like the following:
-
- ::
-
- @QtCore.Slot(int, name='on_spinbox_valueChanged')
- def spinbox_int_value(self, i):
- # i will be an integer.
- pass
-
- @QtCore.Slot(unicode, name='on_spinbox_valueChanged')
- def spinbox_qstring_value(self, s):
- # s will be a Python unicode object.
- pass
-
- The following shows an example using a button when you are not interested in the optional argument:
-
- ::
-
- @QtCore.Slot()
- def on_button_clicked(self):
- pass
-