Qt 4.8
Public Functions | Private Functions | Properties | List of all members
QSignalSpy Class Reference

#include <qsignalspy.h>

Inheritance diagram for QSignalSpy:
QObject QList< QList< QVariant > >

Public Functions

bool isValid () const
 
 QSignalSpy (QObject *obj, const char *aSignal)
 
int qt_metacall (QMetaObject::Call call, int methodId, void **a)
 
QByteArray signal () const
 
- Public Functions inherited from QObject
bool blockSignals (bool b)
 If block is true, signals emitted by this object are blocked (i.e., emitting a signal will not invoke anything connected to it). More...
 
const QObjectListchildren () const
 Returns a list of child objects. More...
 
bool connect (const QObject *sender, const char *signal, const char *member, Qt::ConnectionType type=Qt::AutoConnection) const
 
bool disconnect (const char *signal=0, const QObject *receiver=0, const char *member=0)
 
bool disconnect (const QObject *receiver, const char *member=0)
 
void dumpObjectInfo ()
 Dumps information about signal connections, etc. More...
 
void dumpObjectTree ()
 Dumps a tree of children to the debug output. More...
 
QList< QByteArraydynamicPropertyNames () const
 Returns the names of all properties that were dynamically added to the object using setProperty(). More...
 
virtual bool event (QEvent *)
 This virtual function receives events to an object and should return true if the event e was recognized and processed. More...
 
virtual bool eventFilter (QObject *, QEvent *)
 Filters events if this object has been installed as an event filter for the watched object. More...
 
template<typename T >
findChild (const QString &aName=QString()) const
 Returns the child of this object that can be cast into type T and that is called name, or 0 if there is no such object. More...
 
template<typename T >
QList< T > findChildren (const QString &aName=QString()) const
 Returns all children of this object with the given name that can be cast to type T, or an empty list if there are no such objects. More...
 
template<typename T >
QList< T > findChildren (const QRegExp &re) const
 
bool inherits (const char *classname) const
 Returns true if this object is an instance of a class that inherits className or a QObject subclass that inherits className; otherwise returns false. More...
 
void installEventFilter (QObject *)
 Installs an event filter filterObj on this object. More...
 
bool isWidgetType () const
 Returns true if the object is a widget; otherwise returns false. More...
 
void killTimer (int id)
 Kills the timer with timer identifier, id. More...
 
virtual const QMetaObjectmetaObject () const
 Returns a pointer to the meta-object of this object. More...
 
void moveToThread (QThread *thread)
 Changes the thread affinity for this object and its children. More...
 
QString objectName () const
 
QObjectparent () const
 Returns a pointer to the parent object. More...
 
QVariant property (const char *name) const
 Returns the value of the object's name property. More...
 
Q_INVOKABLE QObject (QObject *parent=0)
 Constructs an object with parent object parent. More...
 
void removeEventFilter (QObject *)
 Removes an event filter object obj from this object. More...
 
void setObjectName (const QString &name)
 
void setParent (QObject *)
 Makes the object a child of parent. More...
 
bool setProperty (const char *name, const QVariant &value)
 Sets the value of the object's name property to value. More...
 
void setUserData (uint id, QObjectUserData *data)
 
bool signalsBlocked () const
 Returns true if signals are blocked; otherwise returns false. More...
 
int startTimer (int interval)
 Starts a timer and returns a timer identifier, or returns zero if it could not start a timer. More...
 
QThreadthread () const
 Returns the thread in which the object lives. More...
 
QObjectUserDatauserData (uint id) const
 
virtual ~QObject ()
 Destroys the object, deleting all its child objects. More...
 
- Public Functions inherited from QList< QList< QVariant > >
void append (const QList< QVariant > &t)
 Inserts value at the end of the list. More...
 
void append (const QList< QList< QVariant > > &t)
 Appends the items of the value list to this list. More...
 
const QList< QVariant > & at (int i) const
 Returns the item at index position i in the list. More...
 
QList< QVariant > & back ()
 This function is provided for STL compatibility. More...
 
const QList< QVariant > & back () const
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More...
 
iterator begin ()
 Returns an STL-style iterator pointing to the first item in the list. More...
 
const_iterator begin () const
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More...
 
void clear ()
 Removes all items from the list. More...
 
const_iterator constBegin () const
 Returns a const STL-style iterator pointing to the first item in the list. More...
 
const_iterator constEnd () const
 Returns a const STL-style iterator pointing to the imaginary item after the last item in the list. More...
 
QBool contains (const QList< QVariant > &t) const
 Returns true if the list contains an occurrence of value; otherwise returns false. More...
 
int count (const QList< QVariant > &t) const
 Returns the number of occurrences of value in the list. More...
 
int count () const
 Returns the number of items in the list. More...
 
void detach ()
 
void detachShared ()
 This prevents needless mallocs, and makes QList more exception safe in case of cleanup work done in destructors on empty lists. More...
 
bool empty () const
 This function is provided for STL compatibility. More...
 
iterator end ()
 Returns an STL-style iterator pointing to the imaginary item after the last item in the list. More...
 
const_iterator end () const
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More...
 
bool endsWith (const QList< QVariant > &t) const
 Returns true if this list is not empty and its last item is equal to value; otherwise returns false. More...
 
iterator erase (iterator pos)
 Removes the item associated with the iterator pos from the list, and returns an iterator to the next item in the list (which may be end()). More...
 
iterator erase (iterator first, iterator last)
 Removes all the items from begin up to (but not including) end. More...
 
QList< QVariant > & first ()
 Returns a reference to the first item in the list. More...
 
const QList< QVariant > & first () const
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More...
 
QList< QVariant > & front ()
 This function is provided for STL compatibility. More...
 
const QList< QVariant > & front () const
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More...
 
int indexOf (const QList< QVariant > &t, int from=0) const
 Returns the index position of the first occurrence of value in the list, searching forward from index position from. More...
 
void insert (int i, const QList< QVariant > &t)
 Inserts value at index position i in the list. More...
 
iterator insert (iterator before, const QList< QVariant > &t)
 Inserts value in front of the item pointed to by the iterator before. More...
 
bool isDetached () const
 
bool isEmpty () const
 Returns true if the list contains no items; otherwise returns false. More...
 
bool isSharedWith (const QList< QList< QVariant > > &other) const
 
QList< QVariant > & last ()
 Returns a reference to the last item in the list. More...
 
const QList< QVariant > & last () const
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More...
 
int lastIndexOf (const QList< QVariant > &t, int from=-1) const
 Returns the index position of the last occurrence of value in the list, searching backward from index position from. More...
 
int length () const
 This function is identical to count(). More...
 
QList< QList< QVariant > > mid (int pos, int length=-1) const
 Returns a list whose elements are copied from this list, starting at position pos. More...
 
void move (int from, int to)
 Moves the item at index position from to index position to. More...
 
bool operator!= (const QList< QList< QVariant > > &l) const
 Returns true if other is not equal to this list; otherwise returns false. More...
 
QList< QList< QVariant > > operator+ (const QList< QList< QVariant > > &l) const
 Returns a list that contains all the items in this list followed by all the items in the other list. More...
 
QList< QList< QVariant > > & operator+= (const QList< QList< QVariant > > &l)
 Appends the items of the other list to this list and returns a reference to this list. More...
 
QList< QList< QVariant > > & operator+= (const QList< QVariant > &t)
 Appends value to the list. More...
 
QList< QList< QVariant > > & operator<< (const QList< QList< QVariant > > &l)
 Appends the items of the other list to this list and returns a reference to this list. More...
 
QList< QList< QVariant > > & operator<< (const QList< QVariant > &t)
 Appends value to the list. More...
 
QList< QList< QVariant > > & operator= (const QList< QList< QVariant > > &l)
 Assigns other to this list and returns a reference to this list. More...
 
bool operator== (const QList< QList< QVariant > > &l) const
 Returns true if other is equal to this list; otherwise returns false. More...
 
const QList< QVariant > & operator[] (int i) const
 Same as at(). More...
 
QList< QVariant > & operator[] (int i)
 Returns the item at index position i as a modifiable reference. More...
 
void pop_back ()
 This function is provided for STL compatibility. More...
 
void pop_front ()
 This function is provided for STL compatibility. More...
 
void prepend (const QList< QVariant > &t)
 Inserts value at the beginning of the list. More...
 
void push_back (const QList< QVariant > &t)
 This function is provided for STL compatibility. More...
 
void push_front (const QList< QVariant > &t)
 This function is provided for STL compatibility. More...
 
 QList ()
 Constructs an empty list. More...
 
 QList (const QList< QList< QVariant > > &l)
 Constructs a copy of other. More...
 
int removeAll (const QList< QVariant > &t)
 Removes all occurrences of value in the list and returns the number of entries removed. More...
 
void removeAt (int i)
 Removes the item at index position i. More...
 
void removeFirst ()
 Removes the first item in the list. More...
 
void removeLast ()
 Removes the last item in the list. More...
 
bool removeOne (const QList< QVariant > &t)
 Removes the first occurrence of value in the list and returns true on success; otherwise returns false. More...
 
void replace (int i, const QList< QVariant > &t)
 Replaces the item at index position i with value. More...
 
void reserve (int size)
 Reserve space for alloc elements. More...
 
void setSharable (bool sharable)
 
int size () const
 Returns the number of items in the list. More...
 
bool startsWith (const QList< QVariant > &t) const
 Returns true if this list is not empty and its first item is equal to value; otherwise returns false. More...
 
void swap (QList< QList< QVariant > > &other)
 Swaps list other with this list. More...
 
void swap (int i, int j)
 Exchange the item at index position i with the item at index position j. More...
 
QList< QVarianttakeAt (int i)
 Removes the item at index position i and returns it. More...
 
QList< QVarianttakeFirst ()
 Removes the first item in the list and returns it. More...
 
QList< QVarianttakeLast ()
 Removes the last item in the list and returns it. More...
 
QSet< QList< QVariant > > toSet () const
 Returns a QSet object with the data contained in this QList. More...
 
std::list< QList< QVariant > > toStdList () const
 Returns a std::list object with the data contained in this QList. More...
 
QVector< QList< QVariant > > toVector () const
 Returns a QVector object with the data contained in this QList. More...
 
QList< QVariantvalue (int i) const
 Returns the value at index position i in the list. More...
 
QList< QVariantvalue (int i, const QList< QVariant > &defaultValue) const
 If the index i is out of bounds, the function returns defaultValue. More...
 
 ~QList ()
 Destroys the list. More...
 

Private Functions

void appendArgs (void **a)
 
void initArgs (const QMetaMethod &member)
 

Properties

QList< int > args
 
QByteArray sig
 

Additional Inherited Members

- Public Types inherited from QList< QList< QVariant > >
typedef const value_typeconst_pointer
 Typedef for const T *. More...
 
typedef const value_typeconst_reference
 Typedef for const T &. More...
 
typedef const_iterator ConstIterator
 Qt-style synonym for QList::const_iterator. More...
 
typedef qptrdiff difference_type
 Typedef for ptrdiff_t. More...
 
typedef iterator Iterator
 Qt-style synonym for QList::iterator. More...
 
typedef value_typepointer
 Typedef for T *. More...
 
typedef value_typereference
 Typedef for T &. More...
 
typedef int size_type
 Typedef for int. More...
 
typedef QList< QVariantvalue_type
 Typedef for T. More...
 
- Public Slots inherited from QObject
void deleteLater ()
 Schedules this object for deletion. More...
 
- Signals inherited from QObject
void destroyed (QObject *=0)
 This signal is emitted immediately before the object obj is destroyed, and can not be blocked. More...
 
- Static Public Functions inherited from QObject
static bool connect (const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
 Creates a connection of the given type from the signal in the sender object to the method in the receiver object. More...
 
static bool connect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method, Qt::ConnectionType type=Qt::AutoConnection)
 
static bool disconnect (const QObject *sender, const char *signal, const QObject *receiver, const char *member)
 Disconnects signal in object sender from method in object receiver. More...
 
static bool disconnect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &member)
 
static uint registerUserData ()
 
static QString tr (const char *sourceText, const char *comment=0, int n=-1)
 
static QString trUtf8 (const char *sourceText, const char *comment=0, int n=-1)
 
- Static Public Functions inherited from QList< QList< QVariant > >
static QList< QList< QVariant > > fromSet (const QSet< QList< QVariant > > &set)
 Returns a QList object with the data contained in set. More...
 
static QList< QList< QVariant > > fromStdList (const std::list< QList< QVariant > > &list)
 Returns a QList object with the data contained in list. More...
 
static QList< QList< QVariant > > fromVector (const QVector< QList< QVariant > > &vector)
 Returns a QList object with the data contained in vector. More...
 
- Public Variables inherited from QList< QList< QVariant > >
QListData::Datad
 
QListData p
 
- Static Public Variables inherited from QObject
static const QMetaObject staticMetaObject
 This variable stores the meta-object for the class. More...
 
- Protected Functions inherited from QObject
virtual void childEvent (QChildEvent *)
 This event handler can be reimplemented in a subclass to receive child events. More...
 
virtual void connectNotify (const char *signal)
 This virtual function is called when something has been connected to signal in this object. More...
 
virtual void customEvent (QEvent *)
 This event handler can be reimplemented in a subclass to receive custom events. More...
 
virtual void disconnectNotify (const char *signal)
 This virtual function is called when something has been disconnected from signal in this object. More...
 
 QObject (QObjectPrivate &dd, QObject *parent=0)
 
int receivers (const char *signal) const
 Returns the number of receivers connected to the signal. More...
 
QObjectsender () const
 Returns a pointer to the object that sent the signal, if called in a slot activated by a signal; otherwise it returns 0. More...
 
int senderSignalIndex () const
 
virtual void timerEvent (QTimerEvent *)
 This event handler can be reimplemented in a subclass to receive timer events for the object. More...
 
- Protected Variables inherited from QObject
QScopedPointer< QObjectDatad_ptr
 
- Static Protected Variables inherited from QObject
static const QMetaObject staticQtMetaObject
 

Detailed Description

Definition at line 61 of file qsignalspy.h.

Constructors and Destructors

◆ QSignalSpy()

QSignalSpy::QSignalSpy ( QObject obj,
const char *  aSignal 
)
inline

Definition at line 64 of file qsignalspy.h.

65  {
66 #ifdef Q_CC_BOR
67  const int memberOffset = QObject::staticMetaObject.methodCount();
68 #else
69  static const int memberOffset = QObject::staticMetaObject.methodCount();
70 #endif
71  Q_ASSERT(obj);
72  Q_ASSERT(aSignal);
73 
74  if (((aSignal[0] - '0') & 0x03) != QSIGNAL_CODE) {
75  qWarning("QSignalSpy: Not a valid signal, use the SIGNAL macro");
76  return;
77  }
78 
80  const QMetaObject *mo = obj->metaObject();
81  int sigIndex = mo->indexOfMethod(ba.constData());
82  if (sigIndex < 0) {
83  qWarning("QSignalSpy: No such signal: '%s'", ba.constData());
84  return;
85  }
86 
87  if (!QMetaObject::connect(obj, sigIndex, this, memberOffset,
89  qWarning("QSignalSpy: QMetaObject::connect returned false. Unable to connect.");
90  return;
91  }
92  sig = ba;
93  initArgs(mo->method(sigIndex));
94  }
The QMetaObject class contains meta-information about Qt objects.
Definition: qobjectdefs.h:304
static bool connect(const QObject *sender, int signal_index, const QObject *receiver, int method_index, int type=0, int *types=0)
Definition: qobject.cpp:3194
static QByteArray normalizedSignature(const char *method)
Normalizes the signature of the given method.
The QByteArray class provides an array of bytes.
Definition: qbytearray.h:135
static const QMetaObject staticMetaObject
This variable stores the meta-object for the class.
Definition: qobject.h:128
void initArgs(const QMetaMethod &member)
Definition: qsignalspy.h:116
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
Q_CORE_EXPORT void qWarning(const char *,...)
const char * constData() const
Returns a pointer to the data stored in the byte array.
Definition: qbytearray.h:433
#define QSIGNAL_CODE
Definition: qobjectdefs.h:244
int indexOfMethod(const char *method) const
Finds method and returns its index; otherwise returns -1.
QByteArray sig
Definition: qsignalspy.h:139
QMetaMethod method(int index) const
Returns the meta-data for the method with the given index.
int methodCount() const
Returns the number of methods known to the meta-object system in this class, including the number of ...
virtual const QMetaObject * metaObject() const
Returns a pointer to the meta-object of this object.

Functions

◆ appendArgs()

void QSignalSpy::appendArgs ( void **  a)
inlineprivate

Definition at line 128 of file qsignalspy.h.

Referenced by qt_metacall().

129  {
130  QList<QVariant> list;
131  for (int i = 0; i < args.count(); ++i) {
132  QMetaType::Type type = static_cast<QMetaType::Type>(args.at(i));
133  list << QVariant(type, a[i + 1]);
134  }
135  append(list);
136  }
The QVariant class acts like a union for the most common Qt data types.
Definition: qvariant.h:92
int type
Definition: qmetatype.cpp:239
QList< int > args
Definition: qsignalspy.h:141
long ASN1_INTEGER_get ASN1_INTEGER * a
int count(const T &t) const
Returns the number of occurrences of value in the list.
Definition: qlist.h:891
void append(const QList< QVariant > &t)
Inserts value at the end of the list.
Definition: qlist.h:507
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
Type
These are the built-in types supported by QMetaType:
Definition: qmetatype.h:64

◆ initArgs()

void QSignalSpy::initArgs ( const QMetaMethod member)
inlineprivate

Definition at line 116 of file qsignalspy.h.

Referenced by QSignalSpy().

117  {
118  QList<QByteArray> params = member.parameterTypes();
119  for (int i = 0; i < params.count(); ++i) {
120  int tp = QMetaType::type(params.at(i).constData());
121  if (tp == QMetaType::Void)
122  qWarning("Don't know how to handle '%s', use qRegisterMetaType to register it.",
123  params.at(i).constData());
124  args << tp;
125  }
126  }
QList< int > args
Definition: qsignalspy.h:141
int count(const T &t) const
Returns the number of occurrences of value in the list.
Definition: qlist.h:891
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
Q_CORE_EXPORT void qWarning(const char *,...)
static int type(const char *typeName)
Returns a handle to the type called typeName, or 0 if there is no such type.
Definition: qmetatype.cpp:607
const char * constData() const
Returns a pointer to the data stored in the byte array.
Definition: qbytearray.h:433
QList< QByteArray > parameterTypes() const
Returns a list of parameter types.

◆ isValid()

bool QSignalSpy::isValid ( ) const
inline

Definition at line 96 of file qsignalspy.h.

96 { return !sig.isEmpty(); }
QByteArray sig
Definition: qsignalspy.h:139
bool isEmpty() const
Returns true if the byte array has size 0; otherwise returns false.
Definition: qbytearray.h:421

◆ qt_metacall()

int QSignalSpy::qt_metacall ( QMetaObject::Call  call,
int  methodId,
void **  a 
)
inline

Definition at line 100 of file qsignalspy.h.

101  {
102  methodId = QObject::qt_metacall(call, methodId, a);
103  if (methodId < 0)
104  return methodId;
105 
106  if (call == QMetaObject::InvokeMetaMethod) {
107  if (methodId == 0) {
108  appendArgs(a);
109  }
110  --methodId;
111  }
112  return methodId;
113  }
void appendArgs(void **a)
Definition: qsignalspy.h:128
long ASN1_INTEGER_get ASN1_INTEGER * a

◆ signal()

QByteArray QSignalSpy::signal ( ) const
inline

Definition at line 97 of file qsignalspy.h.

97 { return sig; }
QByteArray sig
Definition: qsignalspy.h:139

Properties

◆ args

QList<int> QSignalSpy::args
private

Definition at line 141 of file qsignalspy.h.

Referenced by appendArgs(), and initArgs().

◆ sig

QByteArray QSignalSpy::sig
private

Definition at line 139 of file qsignalspy.h.

Referenced by isValid(), QSignalSpy(), and signal().


The documentation for this class was generated from the following file: