Qt 4.8
Public Types | Public Functions | Static Public Functions | Public Variables | List of all members
QMetaObject Class Reference

The QMetaObject class contains meta-information about Qt objects. More...

#include <qobjectdefs.h>

Inheritance diagram for QMetaObject:
QAbstractDynamicMetaObject QAxMetaObject QDBusMetaObject QDeclarativeBoundSignalParameters::MetaObject QDeclarativeOpenMetaObject QDeclarativeProxyMetaObject QDeclarativeVMEMetaObject ModelNodeMetaObject QDeclarativePropertyMapMetaObject QDeclarativeVisualDataModelDataMetaObject QDeclarativeVisualDataModelPartsMetaObject

Public Types

enum  Call {
  InvokeMetaMethod, ReadProperty, WriteProperty, ResetProperty,
  QueryPropertyDesignable, QueryPropertyScriptable, QueryPropertyStored, QueryPropertyEditable,
  QueryPropertyUser, CreateInstance
}
 

Public Functions

QObjectcast (QObject *obj) const
 Returns obj if object obj inherits from this meta-object; otherwise returns 0. More...
 
const QObjectcast (const QObject *obj) const
 Returns obj if object obj inherits from this meta-object; otherwise returns 0. More...
 
QMetaClassInfo classInfo (int index) const
 Returns the meta-data for the item of class information with the given index. More...
 
int classInfoCount () const
 Returns the number of items of class information in this class. More...
 
int classInfoOffset () const
 Returns the class information offset for this class; i.e. More...
 
const char * className () const
 Returns the class name. More...
 
QMetaMethod constructor (int index) const
 Returns the meta-data for the constructor with the given index. More...
 
int constructorCount () const
 Returns the number of constructors in this class. More...
 
QMetaEnum enumerator (int index) const
 Returns the meta-data for the enumerator with the given index. More...
 
int enumeratorCount () const
 Returns the number of enumerators in this class. More...
 
int enumeratorOffset () const
 Returns the enumerator offset for this class; i.e. More...
 
int indexOfClassInfo (const char *name) const
 Finds class information item name and returns its index; otherwise returns -1. More...
 
int indexOfConstructor (const char *constructor) const
 Finds constructor and returns its index; otherwise returns -1. More...
 
int indexOfEnumerator (const char *name) const
 Finds enumerator name and returns its index; otherwise returns -1. More...
 
int indexOfMethod (const char *method) const
 Finds method and returns its index; otherwise returns -1. More...
 
int indexOfProperty (const char *name) const
 Finds property name and returns its index; otherwise returns -1. More...
 
int indexOfSignal (const char *signal) const
 Finds signal and returns its index; otherwise returns -1. More...
 
int indexOfSlot (const char *slot) const
 Finds slot and returns its index; otherwise returns -1. More...
 
QMetaMethod method (int index) const
 Returns the meta-data for the method with the given index. More...
 
int methodCount () const
 Returns the number of methods known to the meta-object system in this class, including the number of properties provided by each base class. More...
 
int methodOffset () const
 Returns the method offset for this class; i.e. More...
 
QObjectnewInstance (QGenericArgument val0=QGenericArgument(0), QGenericArgument val1=QGenericArgument(), QGenericArgument val2=QGenericArgument(), QGenericArgument val3=QGenericArgument(), QGenericArgument val4=QGenericArgument(), QGenericArgument val5=QGenericArgument(), QGenericArgument val6=QGenericArgument(), QGenericArgument val7=QGenericArgument(), QGenericArgument val8=QGenericArgument(), QGenericArgument val9=QGenericArgument()) const
 Constructs a new instance of this class. More...
 
QMetaProperty property (int index) const
 Returns the meta-data for the property with the given index. More...
 
int propertyCount () const
 Returns the number of properties in this class, including the number of properties provided by each base class. More...
 
int propertyOffset () const
 Returns the property offset for this class; i.e. More...
 
int static_metacall (Call, int, void **) const
 
const QMetaObjectsuperClass () const
 Returns the meta-object of the superclass, or 0 if there is no such object. More...
 
QString tr (const char *s, const char *c) const
 
QString tr (const char *s, const char *c, int n) const
 
QString trUtf8 (const char *s, const char *c) const
 
QString trUtf8 (const char *s, const char *c, int n) const
 
QMetaProperty userProperty () const
 Returns the property that has the USER flag set to true. More...
 

Static Public Functions

static void activate (QObject *sender, int signal_index, void **argv)
 
static void activate (QObject *sender, int from_signal_index, int to_signal_index, void **argv)
 
static void activate (QObject *sender, const QMetaObject *, int local_signal_index, void **argv)
 
static void activate (QObject *sender, const QMetaObject *, int from_local_signal_index, int to_local_signal_index, void **argv)
 
static void addGuard (QObject **ptr)
 
static void changeGuard (QObject **ptr, QObject *o)
 
static bool checkConnectArgs (const char *signal, const char *method)
 Returns true if the signal and method arguments are compatible; otherwise returns false. More...
 
static bool connect (const QObject *sender, int signal_index, const QObject *receiver, int method_index, int type=0, int *types=0)
 
static void connectSlotsByName (QObject *o)
 Searches recursively for all child objects of the given object, and connects matching signals from them to slots of object that follow the following form: More...
 
static bool disconnect (const QObject *sender, int signal_index, const QObject *receiver, int method_index)
 
static bool disconnectOne (const QObject *sender, int signal_index, const QObject *receiver, int method_index)
 
static bool invokeMethod (QObject *obj, const char *member, Qt::ConnectionType, QGenericReturnArgument ret, QGenericArgument val0=QGenericArgument(0), QGenericArgument val1=QGenericArgument(), QGenericArgument val2=QGenericArgument(), QGenericArgument val3=QGenericArgument(), QGenericArgument val4=QGenericArgument(), QGenericArgument val5=QGenericArgument(), QGenericArgument val6=QGenericArgument(), QGenericArgument val7=QGenericArgument(), QGenericArgument val8=QGenericArgument(), QGenericArgument val9=QGenericArgument())
 Invokes the member (a signal or a slot name) on the object obj. More...
 
static bool invokeMethod (QObject *obj, const char *member, QGenericReturnArgument ret, QGenericArgument val0=QGenericArgument(0), QGenericArgument val1=QGenericArgument(), QGenericArgument val2=QGenericArgument(), QGenericArgument val3=QGenericArgument(), QGenericArgument val4=QGenericArgument(), QGenericArgument val5=QGenericArgument(), QGenericArgument val6=QGenericArgument(), QGenericArgument val7=QGenericArgument(), QGenericArgument val8=QGenericArgument(), QGenericArgument val9=QGenericArgument())
 
static bool invokeMethod (QObject *obj, const char *member, Qt::ConnectionType type, QGenericArgument val0=QGenericArgument(0), QGenericArgument val1=QGenericArgument(), QGenericArgument val2=QGenericArgument(), QGenericArgument val3=QGenericArgument(), QGenericArgument val4=QGenericArgument(), QGenericArgument val5=QGenericArgument(), QGenericArgument val6=QGenericArgument(), QGenericArgument val7=QGenericArgument(), QGenericArgument val8=QGenericArgument(), QGenericArgument val9=QGenericArgument())
 
static bool invokeMethod (QObject *obj, const char *member, QGenericArgument val0=QGenericArgument(0), QGenericArgument val1=QGenericArgument(), QGenericArgument val2=QGenericArgument(), QGenericArgument val3=QGenericArgument(), QGenericArgument val4=QGenericArgument(), QGenericArgument val5=QGenericArgument(), QGenericArgument val6=QGenericArgument(), QGenericArgument val7=QGenericArgument(), QGenericArgument val8=QGenericArgument(), QGenericArgument val9=QGenericArgument())
 
static int metacall (QObject *, Call, int, void **)
 
static QByteArray normalizedSignature (const char *method)
 Normalizes the signature of the given method. More...
 
static QByteArray normalizedType (const char *type)
 Normalizes a type. More...
 
static void removeGuard (QObject **ptr)
 

Public Variables

struct {
   const uint *   data
 
   const void *   extradata
 
   const char *   stringdata
 
   const QMetaObject *   superdata
 
d
 

Detailed Description

The QMetaObject class contains meta-information about Qt objects.

The Qt Meta-Object System in Qt is responsible for the signals and slots inter-object communication mechanism, runtime type information, and the Qt property system. A single QMetaObject instance is created for each QObject subclass that is used in an application, and this instance stores all the meta-information for the QObject subclass. This object is available as QObject::metaObject().

This class is not normally required for application programming, but it is useful if you write meta-applications, such as scripting engines or GUI builders.

The functions you are most likely to find useful are these:

The index functions indexOfConstructor(), indexOfMethod(), indexOfEnumerator(), and indexOfProperty() map names of constructors, member functions, enumerators, or properties to indexes in the meta-object. For example, Qt uses indexOfMethod() internally when you connect a signal to a slot.

Classes can also have a list of namevalue pairs of additional class information, stored in QMetaClassInfo objects. The number of pairs is returned by classInfoCount(), single pairs are returned by classInfo(), and you can search for pairs with indexOfClassInfo().

See also
QMetaClassInfo, QMetaEnum, QMetaMethod, QMetaProperty, QMetaType, {Meta-Object System}

Definition at line 304 of file qobjectdefs.h.

Enumerations

◆ Call

Warning
This function is not part of the public interface.
  • InvokeSlot
  • EmitSignal
  • ReadProperty
  • WriteProperty
  • ResetProperty
  • QueryPropertyDesignable
  • QueryPropertyScriptable
  • QueryPropertyStored
  • QueryPropertyEditable
  • QueryPropertyUser
  • CreateInstance
Enumerator
InvokeMetaMethod 
ReadProperty 
WriteProperty 
ResetProperty 
QueryPropertyDesignable 
QueryPropertyScriptable 
QueryPropertyStored 
QueryPropertyEditable 
QueryPropertyUser 
CreateInstance 

Definition at line 448 of file qobjectdefs.h.

Functions

◆ activate() [1/4]

void QMetaObject::activate ( QObject sender,
int  signal_index,
void **  argv 
)
static
Warning
This function is not part of the public interface. Obsolete. (signal_index comes from indexOfMethod())

Definition at line 3690 of file qobject.cpp.

Referenced by QDeclarativeVMEMetaObject::list_append(), QDeclarativeVMEMetaObject::list_clear(), QDeclarativeVMEMetaObject::listChanged(), QDBusInterfacePrivate::metacall(), QDeclarativeProxyMetaObject::metaCall(), QDeclarativeOpenMetaObject::metaCall(), QDeclarativeVMEMetaObject::metaCall(), QAxBase::qt_metacall(), QDBusAdaptorConnector::relaySignal(), QDeclarativeContext::setContextProperty(), QDeclarativeOpenMetaObject::setValue(), and QDeclarativeVMEMetaObject::writeVarProperty().

3691 {
3692  const QMetaObject *mo = sender->metaObject();
3693  while (mo->methodOffset() > signal_index)
3694  mo = mo->superClass();
3695  activate(sender, mo, signal_index - mo->methodOffset(), argv);
3696 }
The QMetaObject class contains meta-information about Qt objects.
Definition: qobjectdefs.h:304
int methodOffset() const
Returns the method offset for this class; i.e.
const QMetaObject * superClass() const
Returns the meta-object of the superclass, or 0 if there is no such object.
Definition: qobjectdefs.h:494
static void activate(QObject *sender, int signal_index, void **argv)
Definition: qobject.cpp:3690
virtual const QMetaObject * metaObject() const
Returns a pointer to the meta-object of this object.

◆ activate() [2/4]

void QMetaObject::activate ( QObject sender,
int  from_signal_index,
int  to_signal_index,
void **  argv 
)
static
Warning
This function is not part of the public interface.

Definition at line 3496 of file qobject.cpp.

3497 {
3498  Q_UNUSED(to_signal_index);
3499  activate(sender, from_signal_index, argv);
3500 }
static void activate(QObject *sender, int signal_index, void **argv)
Definition: qobject.cpp:3690
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...
Definition: qglobal.h:1729

◆ activate() [3/4]

void QMetaObject::activate ( QObject sender,
const QMetaObject m,
int  local_signal_index,
void **  argv 
)
static
Warning
This function is not part of the public interface.

Definition at line 3504 of file qobject.cpp.

3506 {
3507  int signalOffset;
3508  int methodOffset;
3509  computeOffsets(m, &signalOffset, &methodOffset);
3510 
3511  int signal_index = signalOffset + local_signal_index;
3512 
3513  if (!sender->d_func()->isSignalConnected(signal_index))
3514  return; // nothing connected to these signals, and no spy
3515 
3516  if (sender->d_func()->blockSig)
3517  return;
3518 
3519  int signal_absolute_index = methodOffset + local_signal_index;
3520 
3521  void *empty_argv[] = { 0 };
3523  qt_signal_spy_callback_set.signal_begin_callback(sender, signal_absolute_index,
3524  argv ? argv : empty_argv);
3525  }
3526 
3527  Qt::HANDLE currentThreadId = QThread::currentThreadId();
3528 
3529  QMutexLocker locker(signalSlotLock(sender));
3530  QObjectConnectionListVector *connectionLists = sender->d_func()->connectionLists;
3531  if (!connectionLists) {
3532  locker.unlock();
3534  qt_signal_spy_callback_set.signal_end_callback(sender, signal_absolute_index);
3535  return;
3536  }
3537  ++connectionLists->inUse;
3538 
3539 
3540  const QObjectPrivate::ConnectionList *list;
3541  if (signal_index < connectionLists->count())
3542  list = &connectionLists->at(signal_index);
3543  else
3544  list = &connectionLists->allsignals;
3545 
3546  do {
3548  if (!c) continue;
3549  // We need to check against last here to ensure that signals added
3550  // during the signal emission are not emitted in this emission.
3551  QObjectPrivate::Connection *last = list->last;
3552 
3553  do {
3554  if (!c->receiver)
3555  continue;
3556 
3557  QObject * const receiver = c->receiver;
3558  const bool receiverInSameThread = currentThreadId == receiver->d_func()->threadData->threadId;
3559 
3560  // determine if this connection should be sent immediately or
3561  // put into the event queue
3562  if ((c->connectionType == Qt::AutoConnection && !receiverInSameThread)
3563  || (c->connectionType == Qt::QueuedConnection)) {
3564  queued_activate(sender, signal_absolute_index, c, argv ? argv : empty_argv);
3565  continue;
3566 #ifndef QT_NO_THREAD
3567  } else if (c->connectionType == Qt::BlockingQueuedConnection) {
3568  locker.unlock();
3569  if (receiverInSameThread) {
3570  qWarning("Qt: Dead lock detected while activating a BlockingQueuedConnection: "
3571  "Sender is %s(%p), receiver is %s(%p)",
3572  sender->metaObject()->className(), sender,
3573  receiver->metaObject()->className(), receiver);
3574  }
3575  QSemaphore semaphore;
3577  c->callFunction,
3578  sender, signal_absolute_index,
3579  0, 0,
3580  argv ? argv : empty_argv,
3581  &semaphore));
3582  semaphore.acquire();
3583  locker.relock();
3584  continue;
3585 #endif
3586  }
3587 
3588  QObjectPrivate::Sender currentSender;
3589  QObjectPrivate::Sender *previousSender = 0;
3590  if (receiverInSameThread) {
3591  currentSender.sender = sender;
3592  currentSender.signal = signal_absolute_index;
3593  currentSender.ref = 1;
3594  previousSender = QObjectPrivate::setCurrentSender(receiver, &currentSender);
3595  }
3596  const QObjectPrivate::StaticMetaCallFunction callFunction = c->callFunction;
3597  const int method_relative = c->method_relative;
3598  if (callFunction && c->method_offset <= receiver->metaObject()->methodOffset()) {
3599  //we compare the vtable to make sure we are not in the destructor of the object.
3600  locker.unlock();
3602  qt_signal_spy_callback_set.slot_begin_callback(receiver, c->method(), argv ? argv : empty_argv);
3603 
3604 #if defined(QT_NO_EXCEPTIONS)
3605  callFunction(receiver, QMetaObject::InvokeMetaMethod, method_relative, argv ? argv : empty_argv);
3606 #else
3607  QT_TRY {
3608  callFunction(receiver, QMetaObject::InvokeMetaMethod, method_relative, argv ? argv : empty_argv);
3609  } QT_CATCH(...) {
3610  locker.relock();
3611  if (receiverInSameThread)
3612  QObjectPrivate::resetCurrentSender(receiver, &currentSender, previousSender);
3613 
3614  --connectionLists->inUse;
3615  Q_ASSERT(connectionLists->inUse >= 0);
3616  if (connectionLists->orphaned && !connectionLists->inUse)
3617  delete connectionLists;
3618  QT_RETHROW;
3619  }
3620 #endif
3623  locker.relock();
3624  } else {
3625  const int method = method_relative + c->method_offset;
3626  locker.unlock();
3627 
3630  method,
3631  argv ? argv : empty_argv);
3632  }
3633 
3634 #if defined(QT_NO_EXCEPTIONS)
3635  metacall(receiver, QMetaObject::InvokeMetaMethod, method, argv ? argv : empty_argv);
3636 #else
3637  QT_TRY {
3638  metacall(receiver, QMetaObject::InvokeMetaMethod, method, argv ? argv : empty_argv);
3639  } QT_CATCH(...) {
3640  locker.relock();
3641  if (receiverInSameThread)
3642  QObjectPrivate::resetCurrentSender(receiver, &currentSender, previousSender);
3643 
3644  --connectionLists->inUse;
3645  Q_ASSERT(connectionLists->inUse >= 0);
3646  if (connectionLists->orphaned && !connectionLists->inUse)
3647  delete connectionLists;
3648  QT_RETHROW;
3649  }
3650 #endif
3651 
3654 
3655  locker.relock();
3656  }
3657 
3658  if (receiverInSameThread)
3659  QObjectPrivate::resetCurrentSender(receiver, &currentSender, previousSender);
3660 
3661  if (connectionLists->orphaned)
3662  break;
3663  } while (c != last && (c = c->nextConnectionList) != 0);
3664 
3665  if (connectionLists->orphaned)
3666  break;
3667  } while (list != &connectionLists->allsignals &&
3668  //start over for all signals;
3669  ((list = &connectionLists->allsignals), true));
3670 
3671  --connectionLists->inUse;
3672  Q_ASSERT(connectionLists->inUse >= 0);
3673  if (connectionLists->orphaned) {
3674  if (!connectionLists->inUse)
3675  delete connectionLists;
3676  } else if (connectionLists->dirty) {
3677  sender->d_func()->cleanConnectionLists();
3678  }
3679 
3680  locker.unlock();
3681 
3683  qt_signal_spy_callback_set.signal_end_callback(sender, signal_absolute_index);
3684 
3685 }
static Sender * setCurrentSender(QObject *receiver, Sender *sender)
Definition: qobject_p.h:269
BeginCallback slot_begin_callback
Definition: qobject_p.h:79
unsigned char c[8]
Definition: qnumeric_p.h:62
The QSemaphore class provides a general counting semaphore.
Definition: qsemaphore.h:57
EndCallback slot_end_callback
Definition: qobject_p.h:81
QObjectPrivate::ConnectionList allsignals
Definition: qobject.cpp:260
static void postEvent(QObject *receiver, QEvent *event)
Adds the event event, with the object receiver as the receiver of the event, to an event queue and re...
static int metacall(QObject *, Call, int, void **)
static void computeOffsets(const QMetaObject *metaobject, int *signalOffset, int *methodOffset)
Definition: qobject.cpp:225
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
The QObject class is the base class of all Qt objects.
Definition: qobject.h:111
BeginCallback signal_begin_callback
Definition: qobject_p.h:79
#define QT_RETHROW
Definition: qglobal.h:1539
int methodOffset() const
Returns the method offset for this class; i.e.
void(* StaticMetaCallFunction)(QObject *, QMetaObject::Call, int, void **)
Definition: qobject_p.h:113
Q_CORE_EXPORT void qWarning(const char *,...)
static void resetCurrentSender(QObject *receiver, Sender *currentSender, Sender *previousSender)
Definition: qobject_p.h:277
void * HANDLE
Definition: qnamespace.h:1671
#define QT_CATCH(A)
Definition: qglobal.h:1537
EndCallback signal_end_callback
Definition: qobject_p.h:81
const T & at(int i) const
Returns the item at index position i in the vector.
Definition: qvector.h:350
static QMutex * signalSlotLock(const QObject *o)
Definition: qobject.cpp:103
Connection * nextConnectionList
Definition: qobject_p.h:120
The QMutexLocker class is a convenience class that simplifies locking and unlocking mutexes...
Definition: qmutex.h:101
static void queued_activate(QObject *sender, int signal, QObjectPrivate::Connection *c, void **argv)
Definition: qobject.cpp:3459
const char * className() const
Returns the class name.
Definition: qobjectdefs.h:491
QSignalSpyCallbackSet Q_CORE_EXPORT qt_signal_spy_callback_set
QMetaMethod method(int index) const
Returns the meta-data for the method with the given index.
StaticMetaCallFunction callFunction
Definition: qobject_p.h:118
#define QT_TRY
Definition: qglobal.h:1536
virtual const QMetaObject * metaObject() const
Returns a pointer to the meta-object of this object.
static Qt::HANDLE currentThreadId()
Returns the thread handle of the currently executing thread.

◆ activate() [4/4]

void QMetaObject::activate ( QObject sender,
const QMetaObject m,
int  from_local_signal_index,
int  to_local_signal_index,
void **  argv 
)
static
Warning
This function is not part of the public interface. Obsolete, called by moc generated code before Qt 4.6 for cloned signals But since Qt 4.6, all clones are connected to their original

Definition at line 3702 of file qobject.cpp.

3704 {
3705  Q_UNUSED(to_local_signal_index);
3706  Q_ASSERT(from_local_signal_index == QMetaObjectPrivate::originalClone(m, to_local_signal_index));
3707  activate(sender, m, from_local_signal_index, argv);
3708 }
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
static int originalClone(const QMetaObject *obj, int local_method_index)
static void activate(QObject *sender, int signal_index, void **argv)
Definition: qobject.cpp:3690
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...
Definition: qglobal.h:1729

◆ addGuard()

void QMetaObject::addGuard ( QObject **  ptr)
static
Warning
This function is not part of the public interface.

Definition at line 390 of file qobject.cpp.

Referenced by QAction::activate(), and QPointer< QAbstractButton >::QPointer().

391 {
392  if (!*ptr)
393  return;
394  GuardHash *hash = guardHash();
395  if (!hash) {
396  *ptr = 0;
397  return;
398  }
399  QMutexLocker locker(guardHashLock());
400  QObjectPrivate::get(*ptr)->hasGuards = true;
401  hash->insert(*ptr, ptr);
402 }
The QMultiHash class is a convenience QHash subclass that provides multi-valued hashes.
Definition: qcontainerfwd.h:58
static uint hash(const uchar *p, int n)
Definition: qhash.cpp:68
uint hasGuards
Definition: qobject.h:104
static QObjectPrivate * get(QObject *o)
Definition: qobject_p.h:177
QHash< Key, T >::iterator insert(const Key &key, const T &value)
Inserts a new item with the key and a value of value.
Definition: qhash.h:934
The QMutexLocker class is a convenience class that simplifies locking and unlocking mutexes...
Definition: qmutex.h:101

◆ cast() [1/2]

QObject * QMetaObject::cast ( QObject obj) const

Returns obj if object obj inherits from this meta-object; otherwise returns 0.

Warning
This function is not part of the public interface.

Definition at line 283 of file qmetaobject.cpp.

Referenced by QScript::QtFunction::execute(), qobject_cast(), qt_qFindChild_helper(), and qt_qFindChildren_helper().

284 {
285  if (obj) {
286  const QMetaObject *m = obj->metaObject();
287  do {
288  if (m == this)
289  return obj;
290  } while ((m = m->d.superdata));
291  }
292  return 0;
293 }
The QMetaObject class contains meta-information about Qt objects.
Definition: qobjectdefs.h:304
const QMetaObject * superdata
Definition: qobjectdefs.h:469
struct QMetaObject::@38 d
virtual const QMetaObject * metaObject() const
Returns a pointer to the meta-object of this object.

◆ cast() [2/2]

const QObject * QMetaObject::cast ( const QObject obj) const

Returns obj if object obj inherits from this meta-object; otherwise returns 0.

Warning
This function is not part of the public interface.

Definition at line 304 of file qmetaobject.cpp.

305 {
306  if (obj) {
307  const QMetaObject *m = obj->metaObject();
308  do {
309  if (m == this)
310  return obj;
311  } while ((m = m->d.superdata));
312  }
313  return 0;
314 }
The QMetaObject class contains meta-information about Qt objects.
Definition: qobjectdefs.h:304
const QMetaObject * superdata
Definition: qobjectdefs.h:469
struct QMetaObject::@38 d
virtual const QMetaObject * metaObject() const
Returns a pointer to the meta-object of this object.

◆ changeGuard()

void QMetaObject::changeGuard ( QObject **  ptr,
QObject o 
)
static
Warning
This function is not part of the public interface.

Definition at line 435 of file qobject.cpp.

Referenced by QPointer< QAbstractButton >::operator=().

436 {
437  GuardHash *hash = guardHash();
438  if (!hash) {
439  *ptr = 0;
440  return;
441  }
442  QMutexLocker locker(guardHashLock());
443  if (o) {
444  hash->insert(o, ptr);
445  QObjectPrivate::get(o)->hasGuards = true;
446  }
447  if (*ptr) {
448  bool more = false; //if the QObject has more pointer attached to it.
449  GuardHash::iterator it = hash->find(*ptr);
450  const GuardHash::iterator end = hash->end();
451  for (; it.key() == *ptr && it != end; ++it) {
452  if (it.value() == ptr) {
453  it = hash->erase(it);
454  if (!more) more = (it != end && it.key() == *ptr);
455  break;
456  }
457  more = true;
458  }
459  if (!more)
460  QObjectPrivate::get(*ptr)->hasGuards = false;
461  }
462  *ptr = o;
463 }
The QMultiHash class is a convenience QHash subclass that provides multi-valued hashes.
Definition: qcontainerfwd.h:58
static uint hash(const uchar *p, int n)
Definition: qhash.cpp:68
#define it(className, varName)
uint hasGuards
Definition: qobject.h:104
T & value() const
Returns a modifiable reference to the current item&#39;s value.
Definition: qhash.h:348
static QObjectPrivate * get(QObject *o)
Definition: qobject_p.h:177
QHash< Key, T >::iterator find(const Key &key, const T &value)
Returns an iterator pointing to the item with the key and value.
Definition: qhash.h:972
const T * ptr(const T &t)
const Key & key() const
Returns the current item&#39;s key as a const reference.
Definition: qhash.h:347
QHash< Key, T >::iterator insert(const Key &key, const T &value)
Inserts a new item with the key and a value of value.
Definition: qhash.h:934
The QMutexLocker class is a convenience class that simplifies locking and unlocking mutexes...
Definition: qmutex.h:101
iterator end()
Returns an STL-style iterator pointing to the imaginary item after the last item in the hash...
Definition: qhash.h:467
The QHash::iterator class provides an STL-style non-const iterator for QHash and QMultiHash.
Definition: qhash.h:330
static const KeyPair *const end
iterator erase(iterator it)
Removes the (key, value) pair associated with the iterator pos from the hash, and returns an iterator...
Definition: qhash.h:827

◆ checkConnectArgs()

bool QMetaObject::checkConnectArgs ( const char *  signal,
const char *  method 
)
static

Returns true if the signal and method arguments are compatible; otherwise returns false.

Both signal and method are expected to be normalized.

See also
normalizedSignature()

Definition at line 964 of file qmetaobject.cpp.

Referenced by QObject::connect(), QObject::inherits(), and signalForMember().

965 {
966  const char *s1 = signal;
967  const char *s2 = method;
968  while (*s1++ != '(') { } // scan to first '('
969  while (*s2++ != '(') { }
970  if (*s2 == ')' || qstrcmp(s1,s2) == 0) // method has no args or
971  return true; // exact match
972  int s1len = qstrlen(s1);
973  int s2len = qstrlen(s2);
974  if (s2len < s1len && strncmp(s1,s2,s2len-1)==0 && s1[s2len-1]==',')
975  return true; // method has less args
976  return false;
977 }
uint qstrlen(const char *str)
Definition: qbytearray.h:79
QMetaMethod method(int index) const
Returns the meta-data for the method with the given index.
int qstrcmp(const QByteArray &str1, const char *str2)
Definition: qbytearray.cpp:336

◆ classInfo()

QMetaClassInfo QMetaObject::classInfo ( int  index) const

Returns the meta-data for the item of class information with the given index.

Example:

class MyClass : public QObject
{
Q_CLASSINFO("author", "Sabrina Schweinsteiger")
Q_CLASSINFO("url", "http://doc.moosesoft.co.uk/1.0/")
public:
...
};
See also
classInfoCount(), classInfoOffset(), indexOfClassInfo()

Definition at line 941 of file qmetaobject.cpp.

Referenced by QAccessibleObjectPrivate::actionList(), QDBusAdaptorConnector::addAdaptor(), QMetaObjectBuilder::addMetaObject(), QAxFactory::classID(), classIDL(), clone(), QClassFactory::CreateInstanceHelper(), QAxClass< T >::createObject(), QDeclarativeMetaType::defaultMethod(), QDeclarativeMetaType::defaultProperty(), QDeclarativeCompiler::deferredProperties(), QAxFactory::eventsID(), QAxFactory::exposeToSuperClass(), QClassFactory::GetLicInfo(), QAxFactory::hasStockEvents(), QAxFactory::interfaceID(), QAxServerBase::Invoke(), QAxServerBase::Load(), qax_clean_type(), qax_generateDocumentation(), qax_noSuchFunction(), QClassFactory::QClassFactory(), qDBusGenerateMetaObjectXml(), QAxBase::querySubObject(), QAxFactory::registerActiveObject(), QAxServerBase::registerActiveObject(), QAxServerBase::Save(), and QAxFactory::validateLicenseKey().

942 {
943  int i = index;
944  i -= classInfoOffset();
945  if (i < 0 && d.superdata)
946  return d.superdata->classInfo(index);
947 
948  QMetaClassInfo result;
949  if (i >= 0 && i < priv(d.data)->classInfoCount) {
950  result.mobj = this;
951  result.handle = priv(d.data)->classInfoData + 2*i;
952  }
953  return result;
954 }
const QMetaObject * mobj
Definition: qmetaobject.h:232
The QMetaClassInfo class provides additional information about a class.
Definition: qmetaobject.h:224
int classInfoOffset() const
Returns the class information offset for this class; i.e.
static const QMetaObjectPrivate * priv(const uint *data)
struct QMetaObject::@38 d
quint16 index

◆ classInfoCount()

int QMetaObject::classInfoCount ( ) const

Returns the number of items of class information in this class.

See also
classInfo(), classInfoOffset(), indexOfClassInfo()

Definition at line 519 of file qmetaobject.cpp.

Referenced by QMetaObjectBuilder::addMetaObject(), and clone().

520 {
521  int n = priv(d.data)->classInfoCount;
522  const QMetaObject *m = d.superdata;
523  while (m) {
524  n += priv(m->d.data)->classInfoCount;
525  m = m->d.superdata;
526  }
527  return n;
528 }
The QMetaObject class contains meta-information about Qt objects.
Definition: qobjectdefs.h:304
const uint * data
Definition: qobjectdefs.h:471
const QMetaObject * superdata
Definition: qobjectdefs.h:469
static const QMetaObjectPrivate * priv(const uint *data)
struct QMetaObject::@38 d

◆ classInfoOffset()

int QMetaObject::classInfoOffset ( ) const

Returns the class information offset for this class; i.e.

the index position of this class's first class information item.

If the class has no superclasses with class information, the offset is 0; otherwise the offset is the sum of all the class information items in the class's superclasses.

See also
classInfo(), classInfoCount(), indexOfClassInfo()

Definition at line 424 of file qmetaobject.cpp.

Referenced by QMetaObjectBuilder::addMetaObject(), classInfo(), clone(), indexOfClassInfo(), qDBusGenerateMetaObjectXml(), and qDBusInterfaceFromMetaObject().

425 {
426  int offset = 0;
427  const QMetaObject *m = d.superdata;
428  while (m) {
429  offset += priv(m->d.data)->classInfoCount;
430  m = m->d.superdata;
431  }
432  return offset;
433 }
The QMetaObject class contains meta-information about Qt objects.
Definition: qobjectdefs.h:304
const uint * data
Definition: qobjectdefs.h:471
const QMetaObject * superdata
Definition: qobjectdefs.h:469
static const QMetaObjectPrivate * priv(const uint *data)
struct QMetaObject::@38 d

◆ className()

const char * QMetaObject::className ( ) const
inline

Returns the class name.

See also
superClass()

Definition at line 491 of file qobjectdefs.h.

Referenced by activate(), ActiveObject::ActiveObject(), QGraphicsLayoutPrivate::addChildLayoutItem(), QLayout::addChildWidget(), QAccessibleWidget::addControllingSignal(), QMetaObjectBuilder::addMetaObject(), QAxScriptManager::addObject(), QState::addTransition(), QGridLayout::addWidget(), QMacStylePrivate::aquaSizeConstrain(), QStyleSheetStyleSelector::attribute(), check_and_warn_compat(), check_method_code(), check_parent_thread(), check_signal_macro(), QCoreApplicationPrivate::checkReceiverThread(), checkWidget(), classIDL(), QDeclarativeCompiler::compileAlias(), QObject::connect(), QAxClass< T >::createObject(), QLayoutPrivate::createSpacerItem(), QObject::disconnect(), QObject::dumpObjectInfo(), dumpRecursive(), QProxyStylePrivate::ensureBaseStyle(), QApplicationPrivate::enterModal_sys(), err_method_notfound(), QCoreApplication::exec(), QScript::QObjectConnectionManager::execute(), QScript::QMetaObjectWrapperObject::execute(), QApplication::font(), fromScriptValue(), QScript::functionConnect(), QScript::functionDisconnect(), QApplicationPrivate::globalEventProcessor(), QDeclarativeOpenMetaObjectTypePrivate::init(), QNetworkReplyImplPrivate::initCacheSaveDevice(), invokeMethod(), keyTypeForObject(), QApplicationPrivate::leaveModal_sys(), make_widget_eventUPP(), QStyleSheetStyle::nativeFrameWidth(), newInstance(), QScriptEnginePrivate::newQObject(), QStyleSheetStyleSelector::nodeNameEquals(), QStyleSheetStyleSelector::nodeNames(), QDeclarativeEngineDebugService::objectData(), objectInheritsXAndXIsCloserThanY(), QDeclarativeDebugService::objectToString(), operator<<(), QApplication::palette(), parentWidget(), QObject::property(), ptr(), qax_generateDocumentation(), qax_readClassInfo(), qax_readInterfaceInfo(), QAxServerBase::QAxServerBase(), QTest::qExec(), QLayout::QLayout(), QScript::qmetaobjectProtoFuncClassName(), qmlExecuteDeferred(), QScript::qobjectProtoFuncToString(), QTest::qPrintDataTags(), QRenderRule::QRenderRule(), QTest::qSignalDumperCallback(), QTest::qSignalDumperCallbackEndSignal(), QTest::qSignalDumperCallbackSlot(), qt_adopted_thread_watcher_function(), qt_aqua_get_known_size(), qt_mac_send_modifiers_changed(), qt_nograb(), QAccessible::queryAccessibleInterface(), QMetaProperty::read(), QDeclarativeEnginePrivate::registerCompositeType(), QStateMachinePrivate::registerSignalTransition(), QDBusAdaptorConnector::relay(), QCoreApplicationPrivate::removePostedEvent(), QGraphicsLayoutPrivate::reparentChildItems(), QKeyMapper::sendKeyEvent(), QMetaObjectBuilder::serialize(), QNetworkReplyImplPrivate::setCachingEnabled(), QWidget::setLayout(), QObject::setProperty(), QDBusPendingCallPrivate::setReplyCallback(), QThreadPrivate::start(), QmlJSDebugger::AbstractLiveEditTool::titleForItem(), QDeclarativeObjectScriptClass::tostring(), QDeclarativeType::typeName(), QAccessible::updateAccessibility(), QDeclarativeQtScriptExpression::updateGuards(), QGLContext::updatePaintDevice(), VARIANTToQVariant(), writeProperty(), and QDeclarativeInfo::~QDeclarativeInfo().

492 { return d.stringdata; }
struct QMetaObject::@38 d

◆ connect()

bool QMetaObject::connect ( const QObject sender,
int  signal_index,
const QObject receiver,
int  method_index,
int  type = 0,
int *  types = 0 
)
static
Warning
This function is not part of the public interface. types is a 0-terminated vector of meta types for queued connections.

if signal_index is -1, then we effectively connect all signals from the sender to the receiver's slot

Definition at line 3194 of file qobject.cpp.

Referenced by QScript::QObjectConnectionManager::addSignalHandler(), QDeclarativePropertyPrivate::connect(), QDeclarativeVMEMetaObject::connectAlias(), QDBusAdaptorConnector::connectAllSignals(), QDeclarativePixmap::connectDownloadProgress(), QDeclarativePixmap::connectFinished(), QDeclarativeRectanglePrivate::getPen(), QDeclarativeBorderImagePrivate::getScaleGrid(), QDeclarativeFlickablePrivate::init(), QDeclarativePathViewPrivate::init(), QAxServerBase::internalActivate(), QAxServerBase::internalConnect(), QDeclarativeBorderImage::load(), menuItemEntry(), QDeclarativePixmapReader::networkRequestDone(), QDeclarativePixmapReader::processJob(), QSignalSpy::QSignalSpy(), QStateMachinePrivate::registerSignalTransition(), QTextControlPrivate::setContent(), and QDeclarativeRectangle::setGradient().

3196 {
3197  signal_index = methodIndexToSignalIndex(sender->metaObject(), signal_index);
3198  return QMetaObjectPrivate::connect(sender, signal_index,
3199  receiver, method_index,
3200  0, //FIXME, we could speed this connection up by computing the relative index
3201  type, types);
3202 }
int type
Definition: qmetatype.cpp:239
static bool connect(const QObject *sender, int signal_index, const QObject *receiver, int method_index_relative, const QMetaObject *rmeta=0, int type=0, int *types=0)
Definition: qobject.cpp:3209
static int methodIndexToSignalIndex(const QMetaObject *metaObject, int signal_index)
Definition: qobject.cpp:3169
static const struct @32 types[]
virtual const QMetaObject * metaObject() const
Returns a pointer to the meta-object of this object.

◆ connectSlotsByName()

void QMetaObject::connectSlotsByName ( QObject object)
static

Searches recursively for all child objects of the given object, and connects matching signals from them to slots of object that follow the following form:

void on_<object name>_<signal name>(<signal parameters>);

Let's assume our object has a child object of type QPushButton with the object name button1. The slot to catch the button's clicked() signal would be:

void on_button1_clicked();
See also
QObject::setObjectName()

Definition at line 3406 of file qobject.cpp.

3407 {
3408  if (!o)
3409  return;
3410  const QMetaObject *mo = o->metaObject();
3411  Q_ASSERT(mo);
3412  const QObjectList list = o->findChildren<QObject *>(QString());
3413  for (int i = 0; i < mo->methodCount(); ++i) {
3414  const char *slot = mo->method(i).signature();
3415  Q_ASSERT(slot);
3416  if (slot[0] != 'o' || slot[1] != 'n' || slot[2] != '_')
3417  continue;
3418  bool foundIt = false;
3419  for(int j = 0; j < list.count(); ++j) {
3420  const QObject *co = list.at(j);
3421  QByteArray objName = co->objectName().toAscii();
3422  int len = objName.length();
3423  if (!len || qstrncmp(slot + 3, objName.data(), len) || slot[len+3] != '_')
3424  continue;
3425  int sigIndex = co->d_func()->signalIndex(slot + len + 4);
3426  if (sigIndex < 0) { // search for compatible signals
3427  const QMetaObject *smo = co->metaObject();
3428  int slotlen = qstrlen(slot + len + 4) - 1;
3429  for (int k = 0; k < co->metaObject()->methodCount(); ++k) {
3430  QMetaMethod method = smo->method(k);
3431  if (method.methodType() != QMetaMethod::Signal)
3432  continue;
3433 
3434  if (!qstrncmp(method.signature(), slot + len + 4, slotlen)) {
3435  int signalOffset, methodOffset;
3436  computeOffsets(method.enclosingMetaObject(), &signalOffset, &methodOffset);
3437  sigIndex = k + - methodOffset + signalOffset;
3438  break;
3439  }
3440  }
3441  }
3442  if (sigIndex < 0)
3443  continue;
3444  if (QMetaObjectPrivate::connect(co, sigIndex, o, i)) {
3445  foundIt = true;
3446  break;
3447  }
3448  }
3449  if (foundIt) {
3450  // we found our slot, now skip all overloads
3451  while (mo->method(i + 1).attributes() & QMetaMethod::Cloned)
3452  ++i;
3453  } else if (!(mo->method(i).attributes() & QMetaMethod::Cloned)) {
3454  qWarning("QMetaObject::connectSlotsByName: No matching signal for %s", slot);
3455  }
3456  }
3457 }
The QMetaObject class contains meta-information about Qt objects.
Definition: qobjectdefs.h:304
char * data()
Returns a pointer to the data stored in the byte array.
Definition: qbytearray.h:429
static bool connect(const QObject *sender, int signal_index, const QObject *receiver, int method_index_relative, const QMetaObject *rmeta=0, int type=0, int *types=0)
Definition: qobject.cpp:3209
QString objectName
the name of this object
Definition: qobject.h:114
The QByteArray class provides an array of bytes.
Definition: qbytearray.h:135
static void computeOffsets(const QMetaObject *metaobject, int *signalOffset, int *methodOffset)
Definition: qobject.cpp:225
int count(const T &t) const
Returns the number of occurrences of value in the list.
Definition: qlist.h:891
The QString class provides a Unicode character string.
Definition: qstring.h:83
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
The QObject class is the base class of all Qt objects.
Definition: qobject.h:111
int methodOffset() const
Returns the method offset for this class; i.e.
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 *,...)
const QMetaObject * enclosingMetaObject() const
Definition: qmetaobject.h:75
int length() const
Same as size().
Definition: qbytearray.h:356
MethodType methodType() const
Returns the type of this method (signal, slot, or method).
uint qstrlen(const char *str)
Definition: qbytearray.h:79
QByteArray toAscii() const Q_REQUIRED_RESULT
Returns an 8-bit representation of the string as a QByteArray.
Definition: qstring.cpp:4014
int qstrncmp(const char *str1, const char *str2, uint len)
Definition: qbytearray.h:101
int attributes() const
QMetaMethod method(int index) const
Returns the meta-data for the method with the given index.
const char * signature() const
Returns the signature of this method (e.g., setValue(double)).
int methodCount() const
Returns the number of methods known to the meta-object system in this class, including the number of ...
The QMetaMethod class provides meta-data about a member function.
Definition: qmetaobject.h:56
virtual const QMetaObject * metaObject() const
Returns a pointer to the meta-object of this object.

◆ constructor()

QMetaMethod QMetaObject::constructor ( int  index) const

Returns the meta-data for the constructor with the given index.

Since
4.5
See also
constructorCount(), newInstance()

Definition at line 814 of file qmetaobject.cpp.

Referenced by QMetaObjectBuilder::addMetaObject(), and QScript::metaMethod().

815 {
816  int i = index;
817  QMetaMethod result;
818  if (priv(d.data)->revision >= 2 && i >= 0 && i < priv(d.data)->constructorCount) {
819  result.mobj = this;
820  result.handle = priv(d.data)->constructorData + 5*i;
821  }
822  return result;
823 }
static const QMetaObjectPrivate * priv(const uint *data)
struct QMetaObject::@38 d
quint16 index
const QMetaObject * mobj
Definition: qmetaobject.h:139
The QMetaMethod class provides meta-data about a member function.
Definition: qmetaobject.h:56

◆ constructorCount()

int QMetaObject::constructorCount ( ) const

Returns the number of constructors in this class.

Since
4.5
See also
constructor(), indexOfConstructor()

Definition at line 445 of file qmetaobject.cpp.

Referenced by QMetaObjectBuilder::addMetaObject(), and QScript::QMetaObjectWrapperObject::execute().

446 {
447  if (priv(d.data)->revision < 2)
448  return 0;
449  return priv(d.data)->constructorCount;
450 }
static const QMetaObjectPrivate * priv(const uint *data)
struct QMetaObject::@38 d

◆ disconnect()

bool QMetaObject::disconnect ( const QObject sender,
int  signal_index,
const QObject receiver,
int  method_index 
)
static
Warning
This function is not part of the public interface.

Definition at line 3276 of file qobject.cpp.

Referenced by QDeclarativeBoundSignal::disconnect(), QDBusAdaptorConnector::disconnectAllSignals(), QScript::QObjectConnectionManager::removeSignalHandler(), QTextControlPrivate::setContent(), QDeclarativeRectangle::setGradient(), QAxServerBase::UIDeactivate(), and QStateMachinePrivate::unregisterSignalTransition().

3278 {
3279  signal_index = methodIndexToSignalIndex(sender->metaObject(), signal_index);
3280  return QMetaObjectPrivate::disconnect(sender, signal_index,
3281  receiver, method_index);
3282 }
static int methodIndexToSignalIndex(const QMetaObject *metaObject, int signal_index)
Definition: qobject.cpp:3169
static bool disconnect(const QObject *sender, int signal_index, const QObject *receiver, int method_index, DisconnectType=DisconnectAll)
Definition: qobject.cpp:3342
virtual const QMetaObject * metaObject() const
Returns a pointer to the meta-object of this object.

◆ disconnectOne()

bool QMetaObject::disconnectOne ( const QObject sender,
int  signal_index,
const QObject receiver,
int  method_index 
)
static
Warning
This function is not part of the public interface.

Disconnect a single signal connection. If QMetaObject::connect() has been called multiple times for the same sender, signal_index, receiver and method_index only one of these connections will be removed.

Definition at line 3290 of file qobject.cpp.

Referenced by QDeclarativeNotifierEndpoint::disconnect().

3292 {
3293  signal_index = methodIndexToSignalIndex(sender->metaObject(), signal_index);
3294  return QMetaObjectPrivate::disconnect(sender, signal_index,
3295  receiver, method_index,
3297 }
static int methodIndexToSignalIndex(const QMetaObject *metaObject, int signal_index)
Definition: qobject.cpp:3169
static bool disconnect(const QObject *sender, int signal_index, const QObject *receiver, int method_index, DisconnectType=DisconnectAll)
Definition: qobject.cpp:3342
virtual const QMetaObject * metaObject() const
Returns a pointer to the meta-object of this object.

◆ enumerator()

QMetaEnum QMetaObject::enumerator ( int  index) const

Returns the meta-data for the enumerator with the given index.

See also
enumeratorCount(), enumeratorOffset(), indexOfEnumerator()

Definition at line 850 of file qmetaobject.cpp.

Referenced by QMetaObjectBuilder::addMetaObject(), QScript::callQtMethod(), classIDL(), QScript::QMetaObjectWrapperObject::deleteProperty(), QAxBase::dynamicCallHelper(), QDeclarativeObjectMethodScriptClass::enumType(), QDeclarativeCompiler::evaluateEnum(), QScript::QMetaObjectWrapperObject::getOwnPropertyDescriptor(), QScript::QMetaObjectWrapperObject::getOwnPropertyNames(), QScript::QMetaObjectWrapperObject::getOwnPropertySlot(), QScript::indexOfMetaEnum(), property(), QScript::QMetaObjectWrapperObject::put(), qax_generateDocumentation(), QBBButtonEventNotifier::QBBButtonEventNotifier(), QDeclarativeBoundSignalParameters::QDeclarativeBoundSignalParameters(), QDeclarativeTypeNameScriptClass::queryProperty(), QDeclarativeCompiler::testQualifiedEnumAssignment(), and QmlJSDebugger::InspectorProtocol::toString().

851 {
852  int i = index;
853  i -= enumeratorOffset();
854  if (i < 0 && d.superdata)
855  return d.superdata->enumerator(index);
856 
857  QMetaEnum result;
858  if (i >= 0 && i < priv(d.data)->enumeratorCount) {
859  result.mobj = this;
860  result.handle = priv(d.data)->enumeratorData + 4*i;
861  }
862  return result;
863 }
The QMetaEnum class provides meta-data about an enumerator.
Definition: qmetaobject.h:147
int enumeratorOffset() const
Returns the enumerator offset for this class; i.e.
uint handle
Definition: qmetaobject.h:171
const QMetaObject * mobj
Definition: qmetaobject.h:170
static const QMetaObjectPrivate * priv(const uint *data)
struct QMetaObject::@38 d
quint16 index

◆ enumeratorCount()

int QMetaObject::enumeratorCount ( ) const

Returns the number of enumerators in this class.

See also
enumerator(), enumeratorOffset(), indexOfEnumerator()

Definition at line 481 of file qmetaobject.cpp.

Referenced by QMetaObjectBuilder::addMetaObject(), classIDL(), QScript::QMetaObjectWrapperObject::deleteProperty(), QAxBase::dynamicCallHelper(), QDeclarativeObjectMethodScriptClass::enumType(), QDeclarativeCompiler::evaluateEnum(), QScript::QMetaObjectWrapperObject::getOwnPropertyDescriptor(), QScript::QMetaObjectWrapperObject::getOwnPropertyNames(), QScript::QMetaObjectWrapperObject::getOwnPropertySlot(), QScript::indexOfMetaEnum(), QScript::QMetaObjectWrapperObject::put(), qax_generateDocumentation(), QDeclarativeBoundSignalParameters::QDeclarativeBoundSignalParameters(), QDeclarativeTypeNameScriptClass::queryProperty(), and QDeclarativeCompiler::testQualifiedEnumAssignment().

482 {
483  int n = priv(d.data)->enumeratorCount;
484  const QMetaObject *m = d.superdata;
485  while (m) {
486  n += priv(m->d.data)->enumeratorCount;
487  m = m->d.superdata;
488  }
489  return n;
490 }
The QMetaObject class contains meta-information about Qt objects.
Definition: qobjectdefs.h:304
const uint * data
Definition: qobjectdefs.h:471
const QMetaObject * superdata
Definition: qobjectdefs.h:469
static const QMetaObjectPrivate * priv(const uint *data)
struct QMetaObject::@38 d

◆ enumeratorOffset()

int QMetaObject::enumeratorOffset ( ) const

Returns the enumerator offset for this class; i.e.

the index position of this class's first enumerator.

If the class has no superclasses with enumerators, the offset is 0; otherwise the offset is the sum of all the enumerators in the class's superclasses.

See also
enumerator(), enumeratorCount(), indexOfEnumerator()

Definition at line 382 of file qmetaobject.cpp.

Referenced by QMetaObjectBuilder::addMetaObject(), classIDL(), enumerator(), and indexOfEnumerator().

383 {
384  int offset = 0;
385  const QMetaObject *m = d.superdata;
386  while (m) {
387  offset += priv(m->d.data)->enumeratorCount;
388  m = m->d.superdata;
389  }
390  return offset;
391 }
The QMetaObject class contains meta-information about Qt objects.
Definition: qobjectdefs.h:304
const uint * data
Definition: qobjectdefs.h:471
const QMetaObject * superdata
Definition: qobjectdefs.h:469
static const QMetaObjectPrivate * priv(const uint *data)
struct QMetaObject::@38 d

◆ indexOfClassInfo()

int QMetaObject::indexOfClassInfo ( const char *  name) const

Finds class information item name and returns its index; otherwise returns -1.

See also
classInfo(), classInfoCount(), classInfoOffset()

Definition at line 788 of file qmetaobject.cpp.

Referenced by QAccessibleObjectPrivate::actionList(), QDBusAdaptorConnector::addAdaptor(), QAxFactory::classID(), classIDL(), clone(), QClassFactory::CreateInstanceHelper(), QAxClass< T >::createObject(), QDeclarativeMetaType::defaultMethod(), QDeclarativeMetaType::defaultProperty(), QDeclarativeCompiler::deferredProperties(), QAxFactory::eventsID(), QAxFactory::exposeToSuperClass(), QClassFactory::GetLicInfo(), QAxFactory::hasStockEvents(), QAxFactory::interfaceID(), QAxServerBase::InternalQueryInterface(), QAxServerBase::Invoke(), QAxServerBase::Load(), qax_clean_type(), qax_generateDocumentation(), qax_noSuchFunction(), QClassFactory::QClassFactory(), qDBusGenerateMetaObjectXml(), qDBusInterfaceFromMetaObject(), QAxFactory::registerActiveObject(), QAxServerBase::registerActiveObject(), QAxServerBase::Save(), and QAxFactory::validateLicenseKey().

789 {
790  int i = -1;
791  const QMetaObject *m = this;
792  while (m && i < 0) {
793  for (i = priv(m->d.data)->classInfoCount-1; i >= 0; --i)
794  if (strcmp(name, m->d.stringdata
795  + m->d.data[priv(m->d.data)->classInfoData + 2*i]) == 0) {
796  i += m->classInfoOffset();
797  break;
798  }
799  m = m->d.superdata;
800  }
801  return i;
802 }
The QMetaObject class contains meta-information about Qt objects.
Definition: qobjectdefs.h:304
const char * stringdata
Definition: qobjectdefs.h:470
const char * name
const uint * data
Definition: qobjectdefs.h:471
int classInfoOffset() const
Returns the class information offset for this class; i.e.
const QMetaObject * superdata
Definition: qobjectdefs.h:469
static const QMetaObjectPrivate * priv(const uint *data)
struct QMetaObject::@38 d

◆ indexOfConstructor()

int QMetaObject::indexOfConstructor ( const char *  constructor) const

Finds constructor and returns its index; otherwise returns -1.

Since
4.5

Note that the constructor has to be in normalized form, as returned by normalizedSignature().

See also
constructor(), constructorCount(), normalizedSignature()

Definition at line 582 of file qmetaobject.cpp.

Referenced by newInstance().

583 {
584  if (priv(d.data)->revision < 2)
585  return -1;
586  for (int i = priv(d.data)->constructorCount-1; i >= 0; --i) {
587  const char *data = d.stringdata + d.data[priv(d.data)->constructorData + 5*i];
588  if (data[0] == constructor[0] && strcmp(constructor + 1, data + 1) == 0) {
589  return i;
590  }
591  }
592  return -1;
593 }
const uint * data
Definition: qobjectdefs.h:471
static const QMetaObjectPrivate * priv(const uint *data)
struct QMetaObject::@38 d
QMetaMethod constructor(int index) const
Returns the meta-data for the constructor with the given index.

◆ indexOfEnumerator()

int QMetaObject::indexOfEnumerator ( const char *  name) const

Finds enumerator name and returns its index; otherwise returns -1.

See also
enumerator(), enumeratorCount(), enumeratorOffset()

Definition at line 734 of file qmetaobject.cpp.

Referenced by QAxBase::dynamicCallHelper(), QAxBase::internalInvoke(), QAxServerBase::Invoke(), property(), QBBButtonEventNotifier::QBBButtonEventNotifier(), and QAxServerBase::qt_metacall().

735 {
736  const QMetaObject *m = this;
737  while (m) {
738  const QMetaObjectPrivate *d = priv(m->d.data);
739  for (int i = d->enumeratorCount - 1; i >= 0; --i) {
740  const char *prop = m->d.stringdata + m->d.data[d->enumeratorData + 4*i];
741  if (name[0] == prop[0] && strcmp(name + 1, prop + 1) == 0) {
742  i += m->enumeratorOffset();
743  return i;
744  }
745  }
746  m = m->d.superdata;
747  }
748  return -1;
749 }
The QMetaObject class contains meta-information about Qt objects.
Definition: qobjectdefs.h:304
int enumeratorOffset() const
Returns the enumerator offset for this class; i.e.
const char * stringdata
Definition: qobjectdefs.h:470
const char * name
const uint * data
Definition: qobjectdefs.h:471
const QMetaObject * superdata
Definition: qobjectdefs.h:469
static const QMetaObjectPrivate * priv(const uint *data)
struct QMetaObject::@38 d

◆ indexOfMethod()

int QMetaObject::indexOfMethod ( const char *  method) const

Finds method and returns its index; otherwise returns -1.

Note that the method has to be in normalized form, as returned by normalizedSignature().

See also
method(), methodCount(), methodOffset(), normalizedSignature()

Definition at line 603 of file qmetaobject.cpp.

Referenced by QDeclarativeMetaType::defaultMethod(), QObject::disconnect(), QDBusConnectionPrivate::findSlot(), QScript::QObjectDelegate::getOwnPropertyDescriptor(), QScript::QObjectDelegate::getOwnPropertySlot(), QNetworkReply::ignoreSslErrors(), QMetaObjectPrivate::indexOfSignalRelative(), invokeMethod(), QTest::invokeMethod(), QStyle::layoutSpacing(), QScript::QObjectDelegate::put(), QDeclarativeExpression::QDeclarativeExpression(), QDeclarativeWatchProxy::QDeclarativeWatchProxy(), QSignalSpy::QSignalSpy(), QTest::qtest_qParseArgs(), QNetworkReply::setSslConfiguration(), and QNetworkReply::sslConfiguration().

604 {
605  const QMetaObject *m = this;
606  int i = indexOfMethodRelative<0>(&m, method, false);
607  if (i < 0) {
608  m = this;
609  i = indexOfMethodRelative<0>(&m, method, true);
610  }
611  if (i >= 0)
612  i += m->methodOffset();
613  return i;
614 }
The QMetaObject class contains meta-information about Qt objects.
Definition: qobjectdefs.h:304
int methodOffset() const
Returns the method offset for this class; i.e.
QMetaMethod method(int index) const
Returns the meta-data for the method with the given index.

◆ indexOfProperty()

int QMetaObject::indexOfProperty ( const char *  name) const

Finds property name and returns its index; otherwise returns -1.

See also
property(), propertyCount(), propertyOffset()

Definition at line 757 of file qmetaobject.cpp.

Referenced by QDeclarativeCompiler::buildValueTypeProperty(), classIDL(), clone(), QDeclarativeCompiler::compileAlias(), ShaderEffectItem::connectPropertySignals(), QDeclarativePropertyCache::create(), QDeclarativeMetaType::defaultProperty(), QScript::QObjectDelegate::deleteProperty(), QAxBase::dynamicCallHelper(), QAxEventSink::findProperty(), QDeclarativePropertyPrivate::findSignalByName(), QScript::QObjectDelegate::getOwnPropertyDescriptor(), QScript::QObjectDelegate::getOwnPropertySlot(), QDeclarativeCompiler::indexOfProperty(), QDeclarativePropertyPrivate::initProperty(), QAxServerBase::Invoke(), QScript::isEnumerableMetaProperty(), QAxServerBase::Load(), QAxEventSink::OnChanged(), QDeclarativeBindingCompilerPrivate::parseName(), QObject::property(), QScript::QObjectDelegate::put(), qDBusPropertyGet(), QDeclarativeValueTypeScriptClass::queryProperty(), QStyleSheetStyle::setProperties(), QObject::setProperty(), setupDBusInterface(), and writeProperty().

758 {
759  const QMetaObject *m = this;
760  while (m) {
761  const QMetaObjectPrivate *d = priv(m->d.data);
762  for (int i = d->propertyCount-1; i >= 0; --i) {
763  const char *prop = m->d.stringdata + m->d.data[d->propertyData + 3*i];
764  if (name[0] == prop[0] && strcmp(name + 1, prop + 1) == 0) {
765  i += m->propertyOffset();
766  return i;
767  }
768  }
769  m = m->d.superdata;
770  }
771 
772  if (priv(this->d.data)->revision >= 3 && (priv(this->d.data)->flags & DynamicMetaObject)) {
774  const_cast<QAbstractDynamicMetaObject *>(static_cast<const QAbstractDynamicMetaObject *>(this));
775 
776  return me->createProperty(name, 0);
777  }
778 
779  return -1;
780 }
The QMetaObject class contains meta-information about Qt objects.
Definition: qobjectdefs.h:304
virtual int createProperty(const char *, const char *)
Definition: qobject_p.h:337
const char * stringdata
Definition: qobjectdefs.h:470
const char * name
const uint * data
Definition: qobjectdefs.h:471
const QMetaObject * superdata
Definition: qobjectdefs.h:469
static const QMetaObjectPrivate * priv(const uint *data)
struct QMetaObject::@38 d
int propertyOffset() const
Returns the property offset for this class; i.e.

◆ indexOfSignal()

int QMetaObject::indexOfSignal ( const char *  signal) const

Finds signal and returns its index; otherwise returns -1.

This is the same as indexOfMethod(), except that it will return -1 if the method exists but isn't a signal.

Note that the signal has to be in normalized form, as returned by normalizedSignature().

See also
indexOfMethod(), normalizedSignature(), method(), methodCount(), methodOffset()

Definition at line 627 of file qmetaobject.cpp.

Referenced by QAxServerBase::ActiveXProc(), QState::addTransition(), checkHRESULT(), QObject::disconnect(), QDeclarativeRectanglePrivate::getPen(), QDeclarativeBorderImagePrivate::getScaleGrid(), QDeclarativeFlickablePrivate::init(), QDeclarativePathViewPrivate::init(), QAxServerBase::internalActivate(), QAxEventSink::Invoke(), QDeclarativeKeysAttached::keyPressed(), QDeclarativeBorderImage::load(), menuItemEntry(), QAxEventSink::OnChanged(), QDeclarativePixmapReply::QDeclarativePixmapReply(), QtWndProc(), QStateMachinePrivate::registerSignalTransition(), QDeclarativePixmapReader::run(), QScriptEnginePrivate::scriptConnect(), QScriptEnginePrivate::scriptDisconnect(), QDBusAbstractAdaptor::setAutoRelaySignals(), QTextControlPrivate::setContent(), QDeclarativeRectangle::setGradient(), and QAxServerBase::UIDeactivate().

628 {
629  const QMetaObject *m = this;
630  int i = QMetaObjectPrivate::indexOfSignalRelative(&m, signal, false);
631  if (i < 0) {
632  m = this;
633  i = QMetaObjectPrivate::indexOfSignalRelative(&m, signal, true);
634  }
635  if (i >= 0)
636  i += m->methodOffset();
637  return i;
638 }
The QMetaObject class contains meta-information about Qt objects.
Definition: qobjectdefs.h:304
static int indexOfSignalRelative(const QMetaObject **baseObject, const char *name, bool normalizeStringData)
Same as QMetaObject::indexOfSignal, but the result is the local offset to the base object...
int methodOffset() const
Returns the method offset for this class; i.e.

◆ indexOfSlot()

int QMetaObject::indexOfSlot ( const char *  slot) const

Finds slot and returns its index; otherwise returns -1.

This is the same as indexOfMethod(), except that it will return -1 if the method exists but isn't a slot.

See also
indexOfMethod(), method(), methodCount(), methodOffset()

Definition at line 673 of file qmetaobject.cpp.

Referenced by QAxBase::dynamicCallHelper(), QDeclarativeRectanglePrivate::getPen(), QDeclarativeBorderImagePrivate::getScaleGrid(), QDeclarativeFlickablePrivate::init(), QDeclarativePathViewPrivate::init(), QAxServerBase::Invoke(), QDeclarativeBorderImage::load(), QDeclarativeImageBase::load(), qDBusUpdateDispatchStatus(), QDeclarativePixmapReader::run(), QDBusConnectionPrivate::setConnection(), QDeclarativeRectangle::setGradient(), QDeclarativeBorderImage::setGridScaledImage(), and QGraphicsView::viewportEvent().

674 {
675  const QMetaObject *m = this;
676  int i = QMetaObjectPrivate::indexOfSlotRelative(&m, slot, false);
677  if (i < 0)
678  i = QMetaObjectPrivate::indexOfSlotRelative(&m, slot, true);
679  if (i >= 0)
680  i += m->methodOffset();
681  return i;
682 }
The QMetaObject class contains meta-information about Qt objects.
Definition: qobjectdefs.h:304
int methodOffset() const
Returns the method offset for this class; i.e.
static int indexOfSlotRelative(const QMetaObject **m, const char *slot, bool normalizeStringData)

◆ invokeMethod() [1/4]

Invokes the member (a signal or a slot name) on the object obj.

Returns true if the member could be invoked. Returns false if there is no such member or the parameters did not match.

The invocation can be either synchronous or asynchronous, depending on type:

  • If type is Qt::DirectConnection, the member will be invoked immediately.

  • If type is Qt::QueuedConnection, a QEvent will be sent and the member is invoked as soon as the application enters the main event loop.

  • If type is Qt::BlockingQueuedConnection, the method will be invoked in the same way as for Qt::QueuedConnection, except that the current thread will block until the event is delivered. Using this connection type to communicate between objects in the same thread will lead to deadlocks.

  • If type is Qt::AutoConnection, the member is invoked synchronously if obj lives in the same thread as the caller; otherwise it will invoke the member asynchronously.

The return value of the member function call is placed in ret. If the invocation is asynchronous, the return value cannot be evaluated. You can pass up to ten arguments (val0, val1, val2, val3, val4, val5, val6, val7, val8, and val9) to the member function.

QGenericArgument and QGenericReturnArgument are internal helper classes. Because signals and slots can be dynamically invoked, you must enclose the arguments using the Q_ARG() and Q_RETURN_ARG() macros. Q_ARG() takes a type name and a const reference of that type; Q_RETURN_ARG() takes a type name and a non-const reference.

You only need to pass the name of the signal or slot to this function, not the entire signature. For example, to asynchronously invoke the animateClick() slot on a QPushButton, use the following code:

QMetaObject::invokeMethod(pushButton, "animateClick",

With asynchronous method invocations, the parameters must be of types that are known to Qt's meta-object system, because Qt needs to copy the arguments to store them in an event behind the scenes. If you try to use a queued connection and get the error message

QMetaObject::invokeMethod: Unable to handle unregistered datatype 'MyType'

call qRegisterMetaType() to register the data type before you call invokeMethod().

To synchronously invoke the compute(QString, int, double) slot on some arbitrary object obj retrieve its return value:

QString retVal;
Q_ARG(QString, "sqrt"),
Q_ARG(int, 42),
Q_ARG(double, 9.7));

If the "compute" slot does not take exactly one QString, one int and one double in the specified order, the call will fail.

See also
Q_ARG(), Q_RETURN_ARG(), qRegisterMetaType(), QMetaMethod::invoke()

Definition at line 1156 of file qmetaobject.cpp.

Referenced by QNetworkReplyImplPrivate::_q_bufferOutgoingDataFinished(), QHttpNetworkConnectionChannel::_q_disconnected(), QHttpNetworkConnectionChannel::_q_error(), QNetworkReplyImplPrivate::_q_networkSessionConnected(), QGraphicsScenePrivate::_q_polishItems(), QHttpPrivate::_q_slotClosed(), QHttpPrivate::_q_slotError(), QHttpPrivate::_q_slotReadyRead(), QHttpThreadDelegate::abortRequest(), QLayout::addChildWidget(), QHttpPrivate::addRequest(), QHttpNetworkConnectionChannel::allDone(), QAudioOutputPrivate::audioDeviceError(), QAudioInputPrivate::audioDeviceError(), QAudioInputPrivate::audioDeviceFull(), QAudioOutputPrivate::audioDeviceIdle(), QHttpNetworkConnectionChannel::closeAndResendCurrentRequest(), QHttpPrivate::closeConn(), QDeclarativeFolderListModel::componentComplete(), QAbstractSocket::connectToHost(), QGraphicsProxyWidget::createProxyForChildWidget(), QAbstractSocket::disconnectFromHost(), QMacStyle::drawControl(), QHttpSocketEngine::emitConnectionNotification(), QSocks5SocketEnginePrivate::emitConnectionNotification(), QHttpSocketEngine::emitReadNotification(), QSocks5SocketEnginePrivate::emitReadNotification(), QHttpNetworkConnectionPrivate::emitReplyError(), QHttpSocketEngine::emitWriteNotification(), QSocks5SocketEnginePrivate::emitWriteNotification(), QNetworkConfigurationManagerPrivate::enablePolling(), QAbstractItemModel::endResetModel(), QSocketNotifier::event(), QWinEventNotifier::event(), QWorkspace::event(), QObject::event(), QStyledItemDelegate::eventFilter(), QItemDelegate::eventFilter(), QPSQLDriverPrivate::exec(), QAudioInputPrivate::feedback(), QHttpThreadDelegate::finishedSlot(), QHttpThreadDelegate::finishedWithErrorSlot(), QAudioOutputPrivate::freeBlocks(), gtkStyleSetCallback(), QHttpNetworkConnectionChannel::handleStatus(), QHttpNetworkConnectionChannel::handleUnexpectedEOF(), QHttpPrivate::init(), QAudioOutputPrivate::inputReady(), QGraphicsSceneBspTreeIndexPrivate::invalidateSortCache(), QSqlDriver::isIdentifierEscaped(), jump(), QWaylandClipboard::keyboardFocus(), QNetworkReplyImplPrivate::migrateBackend(), QNetworkAccessFileBackend::open(), QDesktopServices::openUrl(), QNetworkConfigurationManagerPrivate::performAsyncConfigurationUpdate(), QNetworkConfigurationManagerPrivate::pollEngines(), QNetworkAccessHttpBackend::postRequest(), QStateMachinePrivate::processEvents(), QBBIntegration::QBBIntegration(), QBBSystemLocaleData::QBBSystemLocaleData(), QDBusAbstractAdaptor::QDBusAbstractAdaptor(), QDBusPendingCallWatcher::QDBusPendingCallWatcher(), QDisabledNetworkReply::QDisabledNetworkReply(), qEventCallback(), QTest::qInvokeTestMethodDataEntry(), QPatternist::QIODeviceDelegate::QIODeviceDelegate(), QNetworkReplyDataImpl::QNetworkReplyDataImpl(), QNetworkReplyFileImpl::QNetworkReplyFileImpl(), qNotificationCallback(), QHttpThreadDelegate::readBufferFreed(), QSslSocket::readData(), QHttpNetworkConnectionPrivate::readMoreLater(), QDeclarativeDebugServer::receiveMessage(), QTransportAuth::registerPolicyReceiver(), QHttpNetworkConnectionPrivate::removeReply(), QLayoutPrivate::reparentChildWidgets(), QNetworkManagerEngine::requestUpdate(), QHttpNetworkConnectionChannel::requeueCurrentlyPipelinedRequests(), QHttpNetworkConnectionPrivate::requeueRequest(), QProgressDialog::reset(), QAbstractItemModel::reset(), QHttpNetworkConnectionPrivate::resumeConnection(), QAccessibleTextEdit::scrollToSubstring(), QNetworkAccessHttpBackend::sendCacheContents(), QHttpNetworkConnectionChannel::sendRequest(), QDBusConnectionPrivate::setConnection(), QGraphicsItem::setCursor(), QDirModel::setData(), QDeclarativeFolderListModel::setFolder(), QDBusConnectionPrivate::setPeer(), QGraphicsScenePrivate::setScenePosItemEnabled(), QNetworkReplyImplPrivate::setup(), QBBClipboard::MimeData::setUserMimeData(), QAbstractScrollArea::setViewport(), QTableView::setWordWrap(), QHttpSocketEngine::setWriteNotificationEnabled(), QStyle::standardIcon(), QStateMachine::start(), QHttpThreadDelegate::startRequestSynchronously(), QSqlDriver::stripDelimiters(), QSqlDriver::subscribedToNotifications(), QSqlDriver::subscribeToNotification(), SxeRegistryLocker::SxeRegistryLocker(), QHttpThreadDelegate::synchronousFinishedSlot(), QHttpThreadDelegate::synchronousFinishedWithErrorSlot(), QSingleShotTimer::timerEvent(), QStatusBarPrivate::tryToShowSizeGrip(), QTransportAuth::unregisterPolicyReceiver(), QGraphicsItem::unsetCursor(), QSqlDriver::unsubscribeFromNotification(), QDeclarativeTimer::update(), QGraphicsScene::update(), QNetworkConfigurationManagerPrivate::updateConfigurations(), QTableView::updateGeometries(), QTreeView::updateGeometries(), QGraphicsWidget::updateGeometry(), QAbstractItemView::viewportEvent(), QBuffer::writeData(), QSslSocket::writeData(), and SxeRegistryLocker::~SxeRegistryLocker().

1170 {
1171  if (!obj)
1172  return false;
1173 
1175  int len = qstrlen(member);
1176  if (len <= 0)
1177  return false;
1178  sig.append(member, len);
1179  sig.append('(');
1180 
1181  const char *typeNames[] = {ret.name(), val0.name(), val1.name(), val2.name(), val3.name(),
1182  val4.name(), val5.name(), val6.name(), val7.name(), val8.name(),
1183  val9.name()};
1184 
1185  int paramCount;
1186  for (paramCount = 1; paramCount < MaximumParamCount; ++paramCount) {
1187  len = qstrlen(typeNames[paramCount]);
1188  if (len <= 0)
1189  break;
1190  sig.append(typeNames[paramCount], len);
1191  sig.append(',');
1192  }
1193  if (paramCount == 1)
1194  sig.append(')'); // no parameters
1195  else
1196  sig[sig.size() - 1] = ')';
1197  sig.append('\0');
1198 
1199  int idx = obj->metaObject()->indexOfMethod(sig.constData());
1200  if (idx < 0) {
1202  idx = obj->metaObject()->indexOfMethod(norm.constData());
1203  }
1204 
1205  if (idx < 0 || idx >= obj->metaObject()->methodCount()) {
1206  qWarning("QMetaObject::invokeMethod: No such method %s::%s",
1207  obj->metaObject()->className(), sig.constData());
1208  return false;
1209  }
1210  QMetaMethod method = obj->metaObject()->method(idx);
1211  return method.invoke(obj, type, ret,
1212  val0, val1, val2, val3, val4, val5, val6, val7, val8, val9);
1213 }
const T * constData() const
int type
Definition: qmetatype.cpp:239
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
void append(const T &t)
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
uint qstrlen(const char *str)
Definition: qbytearray.h:79
int indexOfMethod(const char *method) const
Finds method and returns its index; otherwise returns -1.
const char * className() const
Returns the class name.
Definition: qobjectdefs.h:491
QMetaMethod method(int index) const
Returns the meta-data for the method with the given index.
bool invoke(QObject *object, Qt::ConnectionType connectionType, QGenericReturnArgument returnValue, QGenericArgument val0=QGenericArgument(0), QGenericArgument val1=QGenericArgument(), QGenericArgument val2=QGenericArgument(), QGenericArgument val3=QGenericArgument(), QGenericArgument val4=QGenericArgument(), QGenericArgument val5=QGenericArgument(), QGenericArgument val6=QGenericArgument(), QGenericArgument val7=QGenericArgument(), QGenericArgument val8=QGenericArgument(), QGenericArgument val9=QGenericArgument()) const
Invokes this method on the object object.
int methodCount() const
Returns the number of methods known to the meta-object system in this class, including the number of ...
The QMetaMethod class provides meta-data about a member function.
Definition: qmetaobject.h:56
virtual const QMetaObject * metaObject() const
Returns a pointer to the meta-object of this object.
int size() const
const char * name() const
Returns the name set in the constructor.
Definition: qobjectdefs.h:262

◆ invokeMethod() [2/4]

static bool QMetaObject::invokeMethod ( QObject obj,
const char *  member,
QGenericReturnArgument  ret,
QGenericArgument  val0 = QGenericArgument(0),
QGenericArgument  val1 = QGenericArgument(),
QGenericArgument  val2 = QGenericArgument(),
QGenericArgument  val3 = QGenericArgument(),
QGenericArgument  val4 = QGenericArgument(),
QGenericArgument  val5 = QGenericArgument(),
QGenericArgument  val6 = QGenericArgument(),
QGenericArgument  val7 = QGenericArgument(),
QGenericArgument  val8 = QGenericArgument(),
QGenericArgument  val9 = QGenericArgument() 
)
inlinestatic

Definition at line 387 of file qobjectdefs.h.

399  {
400  return invokeMethod(obj, member, Qt::AutoConnection, ret, val0, val1, val2, val3,
401  val4, val5, val6, val7, val8, val9);
402  }
static bool invokeMethod(QObject *obj, const char *member, Qt::ConnectionType, QGenericReturnArgument ret, QGenericArgument val0=QGenericArgument(0), QGenericArgument val1=QGenericArgument(), QGenericArgument val2=QGenericArgument(), QGenericArgument val3=QGenericArgument(), QGenericArgument val4=QGenericArgument(), QGenericArgument val5=QGenericArgument(), QGenericArgument val6=QGenericArgument(), QGenericArgument val7=QGenericArgument(), QGenericArgument val8=QGenericArgument(), QGenericArgument val9=QGenericArgument())
Invokes the member (a signal or a slot name) on the object obj.

◆ invokeMethod() [3/4]

static bool QMetaObject::invokeMethod ( QObject obj,
const char *  member,
Qt::ConnectionType  type,
QGenericArgument  val0 = QGenericArgument(0),
QGenericArgument  val1 = QGenericArgument(),
QGenericArgument  val2 = QGenericArgument(),
QGenericArgument  val3 = QGenericArgument(),
QGenericArgument  val4 = QGenericArgument(),
QGenericArgument  val5 = QGenericArgument(),
QGenericArgument  val6 = QGenericArgument(),
QGenericArgument  val7 = QGenericArgument(),
QGenericArgument  val8 = QGenericArgument(),
QGenericArgument  val9 = QGenericArgument() 
)
inlinestatic

Definition at line 404 of file qobjectdefs.h.

416  {
417  return invokeMethod(obj, member, type, QGenericReturnArgument(), val0, val1, val2,
418  val3, val4, val5, val6, val7, val8, val9);
419  }
int type
Definition: qmetatype.cpp:239
The QGenericReturnArgument class is an internal helper class for marshalling arguments.
Definition: qobjectdefs.h:269
static bool invokeMethod(QObject *obj, const char *member, Qt::ConnectionType, QGenericReturnArgument ret, QGenericArgument val0=QGenericArgument(0), QGenericArgument val1=QGenericArgument(), QGenericArgument val2=QGenericArgument(), QGenericArgument val3=QGenericArgument(), QGenericArgument val4=QGenericArgument(), QGenericArgument val5=QGenericArgument(), QGenericArgument val6=QGenericArgument(), QGenericArgument val7=QGenericArgument(), QGenericArgument val8=QGenericArgument(), QGenericArgument val9=QGenericArgument())
Invokes the member (a signal or a slot name) on the object obj.

◆ invokeMethod() [4/4]

static bool QMetaObject::invokeMethod ( QObject obj,
const char *  member,
QGenericArgument  val0 = QGenericArgument(0),
QGenericArgument  val1 = QGenericArgument(),
QGenericArgument  val2 = QGenericArgument(),
QGenericArgument  val3 = QGenericArgument(),
QGenericArgument  val4 = QGenericArgument(),
QGenericArgument  val5 = QGenericArgument(),
QGenericArgument  val6 = QGenericArgument(),
QGenericArgument  val7 = QGenericArgument(),
QGenericArgument  val8 = QGenericArgument(),
QGenericArgument  val9 = QGenericArgument() 
)
inlinestatic

Definition at line 421 of file qobjectdefs.h.

432  {
433  return invokeMethod(obj, member, Qt::AutoConnection, QGenericReturnArgument(), val0,
434  val1, val2, val3, val4, val5, val6, val7, val8, val9);
435  }
The QGenericReturnArgument class is an internal helper class for marshalling arguments.
Definition: qobjectdefs.h:269
static bool invokeMethod(QObject *obj, const char *member, Qt::ConnectionType, QGenericReturnArgument ret, QGenericArgument val0=QGenericArgument(0), QGenericArgument val1=QGenericArgument(), QGenericArgument val2=QGenericArgument(), QGenericArgument val3=QGenericArgument(), QGenericArgument val4=QGenericArgument(), QGenericArgument val5=QGenericArgument(), QGenericArgument val6=QGenericArgument(), QGenericArgument val7=QGenericArgument(), QGenericArgument val8=QGenericArgument(), QGenericArgument val9=QGenericArgument())
Invokes the member (a signal or a slot name) on the object obj.

◆ metacall()

int QMetaObject::metacall ( QObject object,
Call  cl,
int  idx,
void **  argv 
)
static
Warning
This function is not part of the public interface.

Definition at line 249 of file qmetaobject.cpp.

Referenced by QDeclarativeObjectMethodScriptClass::callMethod(), QScript::callQtMethod(), QDeclarativeComponentPrivate::complete(), QDeclarativeNotifier::emitNotify(), QDeclarativeCompiledBindingsPrivate::findproperty(), QDeclarativePropertyPrivate::initProperty(), QMetaMethod::invoke(), QMetaProperty::isDesignable(), QMetaProperty::isScriptable(), QMetaProperty::isStored(), QMetaProperty::isUser(), QDeclarativeVMEMetaObject::metaCall(), QDeclarativeListScriptClass::newList(), QMetaCallEvent::placeMetaCall(), QDeclarativeObjectScriptClass::property(), QDeclarativeListReference::QDeclarativeListReference(), QDeclarativePointFValueType::read(), QDeclarativePointValueType::read(), QDeclarativeSizeFValueType::read(), QDeclarativeSizeValueType::read(), QDeclarativeRectFValueType::read(), QMetaProperty::read(), QDeclarativeRectValueType::read(), QDeclarativeVector2DValueType::read(), QDeclarativeVector3DValueType::read(), QDeclarativeVector4DValueType::read(), QDeclarativeQuaternionValueType::read(), QDeclarativeMatrix4x4ValueType::read(), QDeclarativeEasingValueType::read(), QDeclarativeFontValueType::read(), QDeclarativePropertyPrivate::readValueProperty(), QDeclarativeProperty::reset(), QMetaProperty::reset(), QDeclarativeCompiledBindingsPrivate::run(), QDeclarativeObjectScriptClass::setProperty(), QDeclarativeVisualDataModel::stringValue(), QDeclarativeBinding::update(), QPropertyAnimationPrivate::updateProperty(), QDeclarativePropertyPrivate::write(), QDeclarativePointFValueType::write(), QDeclarativePointValueType::write(), QDeclarativeSizeFValueType::write(), QDeclarativeSizeValueType::write(), QDeclarativeRectFValueType::write(), QMetaProperty::write(), QDeclarativeRectValueType::write(), QDeclarativeVector2DValueType::write(), QDeclarativeVector3DValueType::write(), QDeclarativeVector4DValueType::write(), QDeclarativeQuaternionValueType::write(), QDeclarativeMatrix4x4ValueType::write(), QDeclarativeEasingValueType::write(), QDeclarativeFontValueType::write(), and QDeclarativePropertyPrivate::writeEnumProperty().

250 {
251  if (QMetaObject *mo = object->d_ptr->metaObject)
252  return static_cast<QAbstractDynamicMetaObject*>(mo)->metaCall(cl, idx, argv);
253  else
254  return object->qt_metacall(cl, idx, argv);
255 }
The QMetaObject class contains meta-information about Qt objects.
Definition: qobjectdefs.h:304
QMetaObject * metaObject
Definition: qobject.h:107
QScopedPointer< QObjectData > d_ptr
Definition: qobject.h:320

◆ method()

QMetaMethod QMetaObject::method ( int  index) const

Returns the meta-data for the method with the given index.

See also
methodCount(), methodOffset(), indexOfMethod()

Definition at line 830 of file qmetaobject.cpp.

Referenced by QAccessibleObjectPrivate::actionList(), QGraphicsScene::addItem(), QMetaObjectBuilder::addMetaObject(), QScript::QObjectConnectionManager::addSignalHandler(), QDeclarativePropertyCache::append(), QDeclarativeEngineDebugService::buildObjectDump(), QDeclarativeObjectMethodScriptClass::callOverloaded(), QDBusAbstractInterface::callWithArgumentList(), checkConnectArgs(), classIDL(), QDeclarativeObjectMethodScriptClass::connect(), QDeclarativePropertyPrivate::connect(), QObject::connect(), connectSlotsByName(), QDeclarativePropertyCache::create(), QDeclarativeMetaType::defaultMethod(), QDeclarativeNotifierEndpoint::disconnect(), QDeclarativeObjectMethodScriptClass::disconnect(), QObject::dumpObjectInfo(), QAxBase::dynamicCallHelper(), QScript::QObjectConnectionManager::execute(), QDeclarativePropertyPrivate::findSignalByName(), QDBusConnectionPrivate::findSlot(), findSlot(), QScript::functionConnect(), QScript::functionDisconnect(), QAxScript::functions(), generateInterfaceXml(), QScript::QObjectDelegate::getOwnPropertyDescriptor(), QScript::QObjectDelegate::getOwnPropertyNames(), QScript::QObjectDelegate::getOwnPropertySlot(), QStateMachinePrivate::handleTransitionSignal(), indexOfMethod(), QDeclarativeTypePrivate::init(), QAxServerBase::internalConnect(), QAxBase::internalInvoke(), QAxServerBase::Invoke(), QAxEventSink::Invoke(), invokeMethod(), QTest::invokeMethod(), QDeclarativeKeysAttached::keyPressed(), QDBusInterfacePrivate::metacall(), QDeclarativeProxyMetaObject::metaCall(), QScript::metaMethod(), QDeclarativeProperty::method(), QScript::QtFunction::mostGeneralMethod(), QDeclarativePropertyCache::Data::name(), QMetaProperty::notifySignal(), QScript::QtFunction::overloadedIndexes(), QScript::QObjectDelegate::put(), qax_generateDocumentation(), qax_noSuchFunction(), qDBusUpdateDispatchStatus(), QTest::qInvokeTestMethods(), QTest::qPrintDataTags(), QTest::qPrintTestSlots(), QScriptContextInfoPrivate::QScriptContextInfoPrivate(), QTest::qSignalDumperCallback(), QTest::qSignalDumperCallbackSlot(), QSignalSpy::QSignalSpy(), QAxBase::qt_metacall(), QAxServerBase::qt_metacall(), queued_activate(), QStateMachinePrivate::registerSignalTransition(), QDeclarativeObjectMethodScriptClass::relatedMethod(), QDBusAdaptorConnector::relay(), QDBusConnectionPrivate::relaySignal(), QScript::QObjectConnectionManager::removeSignalHandler(), QDBusAbstractAdaptor::setAutoRelaySignals(), and setupDBusInterface().

831 {
832  int i = index;
833  i -= methodOffset();
834  if (i < 0 && d.superdata)
835  return d.superdata->method(index);
836 
837  QMetaMethod result;
838  if (i >= 0 && i < priv(d.data)->methodCount) {
839  result.mobj = this;
840  result.handle = priv(d.data)->methodData + 5*i;
841  }
842  return result;
843 }
int methodOffset() const
Returns the method offset for this class; i.e.
static const QMetaObjectPrivate * priv(const uint *data)
struct QMetaObject::@38 d
quint16 index
const QMetaObject * mobj
Definition: qmetaobject.h:139
The QMetaMethod class provides meta-data about a member function.
Definition: qmetaobject.h:56

◆ methodCount()

int QMetaObject::methodCount ( ) const

Returns the number of methods known to the meta-object system in this class, including the number of properties provided by each base class.

These include signals and slots as well as member functions declared with the Q_INVOKABLE macro.

Use code like the following to obtain a QStringList containing the methods specific to a given class:

const QMetaObject* metaObject = obj->metaObject();
QStringList methods;
for(int i = metaObject->methodOffset(); i < metaObject->methodCount(); ++i)
methods << QString::fromLatin1(metaObject->method(i).signature());
See also
method(), methodOffset(), indexOfMethod()

Definition at line 465 of file qmetaobject.cpp.

Referenced by QAccessibleObjectPrivate::actionList(), QMetaObjectBuilder::addMetaObject(), QDeclarativePropertyCache::append(), QDBusAbstractInterface::callWithArgumentList(), classIDL(), connectSlotsByName(), QDeclarativePropertyCache::create(), QDeclarativePropertyPrivate::findSignalByName(), findSlot(), QAxScript::functions(), generateInterfaceXml(), QScript::QObjectDelegate::getOwnPropertyDescriptor(), QScript::QObjectDelegate::getOwnPropertyNames(), QScript::QObjectDelegate::getOwnPropertySlot(), QDeclarativeBoundSignal::init(), QDeclarativeTypePrivate::init(), QAxServerBase::internalConnect(), QAxBase::internalInvoke(), QAxServerBase::Invoke(), invokeMethod(), QDeclarativeProxyMetaObject::metaCall(), QDeclarativeVMEMetaObject::metaCall(), qax_generateDocumentation(), qax_noSuchFunction(), qDBusGenerateMetaObjectXml(), QDeclarativeCompiledBindings::QDeclarativeCompiledBindings(), QTest::qInvokeTestMethods(), QTest::qPrintDataTags(), QTest::qPrintTestSlots(), QSignalSpy::QSignalSpy(), QAxBase::qt_metacall(), QDeclarativeObjectMethodScriptClass::relatedMethod(), QDBusAbstractAdaptor::setAutoRelaySignals(), QDeclarativeContext::setContextProperty(), setupDBusInterface(), and QDeclarativePropertyCache::update().

466 {
467  int n = priv(d.data)->methodCount;
468  const QMetaObject *m = d.superdata;
469  while (m) {
470  n += priv(m->d.data)->methodCount;
471  m = m->d.superdata;
472  }
473  return n;
474 }
The QMetaObject class contains meta-information about Qt objects.
Definition: qobjectdefs.h:304
const uint * data
Definition: qobjectdefs.h:471
const QMetaObject * superdata
Definition: qobjectdefs.h:469
static const QMetaObjectPrivate * priv(const uint *data)
struct QMetaObject::@38 d

◆ methodOffset()

int QMetaObject::methodOffset ( ) const

Returns the method offset for this class; i.e.

the index position of this class's first member function.

The offset is the sum of all the methods in the class's superclasses (which is always positive since QObject has the deleteLater() slot and a destroyed() signal).

See also
method(), methodCount(), indexOfMethod()

Definition at line 360 of file qmetaobject.cpp.

Referenced by activate(), QMetaObjectBuilder::addMetaObject(), QScript::QObjectConnectionManager::addSignalHandler(), QDeclarativePropertyCache::append(), QScript::callQtMethod(), classIDL(), QMetaObjectPrivate::connect(), QObject::connect(), QDeclarativeVMEMetaObject::connectAlias(), QDeclarativeVMEMetaObject::connectAliasSignal(), flush_vme_signal(), QAxScript::functions(), QScript::QObjectDelegate::getOwnPropertyDescriptor(), QScript::QObjectDelegate::getOwnPropertyNames(), QScript::QObjectDelegate::getOwnPropertySlot(), indexOfMethod(), indexOfSignal(), indexOfSlot(), QAxBase::internalInvoke(), QDeclarativeVMEMetaObject::listChanged(), QDBusInterfacePrivate::metacall(), QDeclarativeProxyMetaObject::metaCall(), QDeclarativeVMEMetaObject::metaCall(), method(), methodIndexToSignalIndex(), QMetaProperty::notifySignalIndex(), QScript::QObjectDelegate::put(), qax_generateDocumentation(), QDeclarativeVMEMetaObject::QDeclarativeVMEMetaObject(), QAxBase::qt_metacall(), QStateMachinePrivate::registerSignalTransition(), QScript::QObjectConnectionManager::removeSignalHandler(), QDeclarativeVMEMetaObject::setVmeMethod(), QStateMachinePrivate::unregisterSignalTransition(), QDeclarativeVMEMetaObject::vmeMethod(), QDeclarativeVMEMetaObject::vmeMethodLineNumber(), and QDeclarativeVMEMetaObject::writeVarProperty().

361 {
362  int offset = 0;
363  const QMetaObject *m = d.superdata;
364  while (m) {
365  offset += priv(m->d.data)->methodCount;
366  m = m->d.superdata;
367  }
368  return offset;
369 }
The QMetaObject class contains meta-information about Qt objects.
Definition: qobjectdefs.h:304
const uint * data
Definition: qobjectdefs.h:471
const QMetaObject * superdata
Definition: qobjectdefs.h:469
static const QMetaObjectPrivate * priv(const uint *data)
struct QMetaObject::@38 d

◆ newInstance()

Constructs a new instance of this class.

Since
4.5

You can pass up to ten arguments (val0, val1, val2, val3, val4, val5, val6, val7, val8, and val9) to the constructor. Returns the new object, or 0 if no suitable constructor is available.

Note that only constructors that are declared with the Q_INVOKABLE modifier are made available through the meta-object system.

See also
Q_ARG(), constructor()

Definition at line 169 of file qmetaobject.cpp.

179 {
180  QByteArray constructorName = className();
181  {
182  int idx = constructorName.lastIndexOf(':');
183  if (idx != -1)
184  constructorName.remove(0, idx+1); // remove qualified part
185  }
187  sig.append(constructorName.constData(), constructorName.length());
188  sig.append('(');
189 
190  enum { MaximumParamCount = 10 };
191  const char *typeNames[] = {val0.name(), val1.name(), val2.name(), val3.name(), val4.name(),
192  val5.name(), val6.name(), val7.name(), val8.name(), val9.name()};
193 
194  int paramCount;
195  for (paramCount = 0; paramCount < MaximumParamCount; ++paramCount) {
196  int len = qstrlen(typeNames[paramCount]);
197  if (len <= 0)
198  break;
199  sig.append(typeNames[paramCount], len);
200  sig.append(',');
201  }
202  if (paramCount == 0)
203  sig.append(')'); // no parameters
204  else
205  sig[sig.size() - 1] = ')';
206  sig.append('\0');
207 
208  int idx = indexOfConstructor(sig.constData());
209  if (idx < 0) {
211  idx = indexOfConstructor(norm.constData());
212  }
213  if (idx < 0)
214  return 0;
215 
216  QVariant ret(QMetaType::QObjectStar, (void*)0);
217  void *param[] = {ret.data(), val0.data(), val1.data(), val2.data(), val3.data(), val4.data(),
218  val5.data(), val6.data(), val7.data(), val8.data(), val9.data()};
219 
220  if (static_metacall(CreateInstance, idx, param) >= 0)
221  return 0;
222  return *reinterpret_cast<QObject**>(param[0]);
223 }
The QVariant class acts like a union for the most common Qt data types.
Definition: qvariant.h:92
const T * constData() const
void * data() const
Returns the data set in the constructor.
Definition: qobjectdefs.h:261
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
int static_metacall(Call, int, void **) const
int indexOfConstructor(const char *constructor) const
Finds constructor and returns its index; otherwise returns -1.
The QObject class is the base class of all Qt objects.
Definition: qobject.h:111
void append(const T &t)
int lastIndexOf(char c, int from=-1) const
Returns the index position of the last occurrence of character ch in the byte array, searching backward from index position from.
int length() const
Same as size().
Definition: qbytearray.h:356
const char * constData() const
Returns a pointer to the data stored in the byte array.
Definition: qbytearray.h:433
uint qstrlen(const char *str)
Definition: qbytearray.h:79
const char * className() const
Returns the class name.
Definition: qobjectdefs.h:491
QByteArray & remove(int index, int len)
Removes len bytes from the array, starting at index position pos, and returns a reference to the arra...
int size() const
const char * name() const
Returns the name set in the constructor.
Definition: qobjectdefs.h:262

◆ normalizedSignature()

QByteArray QMetaObject::normalizedSignature ( const char *  method)
static

Normalizes the signature of the given method.

Qt uses normalized signatures to decide whether two given signals and slots are compatible. Normalization reduces whitespace to a minimum, moves 'const' to the front where appropriate, removes 'const' from value types and replaces const references with values.

See also
checkConnectArgs(), normalizedType()

Definition at line 1058 of file qmetaobject.cpp.

Referenced by QAccessibleObjectPrivate::actionList(), QAccessibleWidget::addControllingSignal(), QState::addTransition(), QObject::connect(), QObject::disconnect(), QAxBase::dynamicCallHelper(), QScript::QObjectDelegate::getOwnPropertyDescriptor(), QScript::QObjectDelegate::getOwnPropertySlot(), QMetaObjectBuilder::indexOfConstructor(), QMetaObjectBuilder::indexOfMethod(), indexOfMethodRelative(), QMetaObjectBuilder::indexOfSignal(), QMetaObjectBuilder::indexOfSlot(), QObject::inherits(), QMetaMethod::invoke(), invokeMethod(), MetaObjectGenerator::metaObject(), newInstance(), QDBusMetaObjectGenerator::parseMethods(), QDBusMetaObjectGenerator::parseSignals(), QDBusConnectionPrivate::prepareHook(), QScript::QObjectDelegate::put(), QSignalSpy::QSignalSpy(), QObject::receivers(), QStateMachinePrivate::registerSignalTransition(), QScriptEnginePrivate::scriptConnect(), QScriptEnginePrivate::scriptDisconnect(), QDBusAbstractAdaptor::setAutoRelaySignals(), QDBusPendingCallPrivate::setReplyCallback(), and signalForMember().

1059 {
1060  QByteArray result;
1061  if (!method || !*method)
1062  return result;
1063  int len = int(strlen(method));
1064  QVarLengthArray<char> stackbuf(len + 1);
1065  char *d = stackbuf.data();
1067 
1068  result.reserve(len);
1069 
1070  int argdepth = 0;
1071  int templdepth = 0;
1072  while (*d) {
1073  if (argdepth == 1) {
1074  d = qNormalizeType(d, templdepth, result);
1075  if (!*d) //most likely an invalid signature.
1076  break;
1077  }
1078  if (*d == '(')
1079  ++argdepth;
1080  if (*d == ')')
1081  --argdepth;
1082  result += *d++;
1083  }
1084 
1085  return result;
1086 }
static char * qNormalizeType(char *d, int &templdepth, QByteArray &result)
The QByteArray class provides an array of bytes.
Definition: qbytearray.h:135
struct QMetaObject::@38 d
QMetaMethod method(int index) const
Returns the meta-data for the method with the given index.
void reserve(int size)
Attempts to allocate memory for at least size bytes.
Definition: qbytearray.h:449
static void qRemoveWhitespace(const char *s, char *d)

◆ normalizedType()

QByteArray QMetaObject::normalizedType ( const char *  type)
static

Normalizes a type.

Since
4.2

See QMetaObject::normalizedSignature() for a description on how Qt normalizes.

Example:

QByteArray normType = QMetaObject::normalizedType(" int const *");
// normType is now "const int*"
See also
normalizedSignature()

Definition at line 1032 of file qmetaobject.cpp.

Referenced by QMetaType::registerType(), QMetaType::registerTypedef(), QMetaMethodBuilder::setReturnType(), QMetaType::type(), and QMetaType::unregisterType().

1033 {
1034  QByteArray result;
1035 
1036  if (!type || !*type)
1037  return result;
1038 
1039  QVarLengthArray<char> stackbuf(qstrlen(type) + 1);
1040  qRemoveWhitespace(type, stackbuf.data());
1041  int templdepth = 0;
1042  qNormalizeType(stackbuf.data(), templdepth, result);
1043 
1044  return result;
1045 }
int type
Definition: qmetatype.cpp:239
static char * qNormalizeType(char *d, int &templdepth, QByteArray &result)
The QByteArray class provides an array of bytes.
Definition: qbytearray.h:135
uint qstrlen(const char *str)
Definition: qbytearray.h:79
static void qRemoveWhitespace(const char *s, char *d)

◆ property()

QMetaProperty QMetaObject::property ( int  index) const

Returns the meta-data for the property with the given index.

If no such property exists, a null QMetaProperty is returned.

See also
propertyCount(), propertyOffset(), indexOfProperty()

Definition at line 871 of file qmetaobject.cpp.

Referenced by QMetaObjectBuilder::addMetaObject(), MetaObjectGenerator::addSlot(), QDeclarativeWatcher::addWatch(), QDeclarativePropertyCache::append(), QDeclarativeCompiler::buildBinding(), QDeclarativeCompiler::buildGroupedProperty(), QDeclarativeEngineDebugService::buildObjectDump(), QDeclarativeCompiler::buildProperty(), QDeclarativeCompiler::buildPropertyLiteralAssignment(), QDeclarativeCompiler::buildPropertyObjectAssignment(), QDeclarativeCompiler::buildPropertyOnAssignment(), QDeclarativeCompiler::buildValueTypeProperty(), classIDL(), clone(), QDeclarativeCompiler::compileAlias(), QDeclarativeVMEMetaObject::connectAlias(), QDeclarativeProperty::connectNotifySignal(), ShaderEffectItem::connectPropertySignals(), QDeclarativeContext::contextProperty(), QDeclarativePropertyCache::create(), QDeclarativeMetaType::defaultProperty(), QScript::QObjectDelegate::deleteProperty(), QDeclarativeCompiler::doesPropertyExist(), QAxBase::dynamicCallHelper(), QScript::QtPropertyFunction::execute(), QDeclarativeBindingCompilerPrivate::fetch(), QDeclarativeCompiledBindingsPrivate::findproperty(), QAxEventSink::findProperty(), QDeclarativePropertyPrivate::findSignalByName(), generateInterfaceXml(), QDeclarativeCompiler::genPropertyAssignment(), QScript::QObjectDelegate::getOwnPropertyDescriptor(), QScript::QObjectDelegate::getOwnPropertyNames(), QScript::QObjectDelegate::getOwnPropertySlot(), QDeclarativeProperty::hasNotifySignal(), QDeclarativeTypePrivate::init(), QDeclarativeVisualDataModelDataMetaObject::initialValue(), QDeclarativePropertyPrivate::initProperty(), QAxBase::internalProperty(), QAxServerBase::Invoke(), QDeclarativeProperty::isDesignable(), QAxServerBase::isPropertyExposed(), QAxServerBase::Load(), QDeclarativeVMEMetaObject::metaCall(), QDeclarativeProperty::name(), QDeclarativePropertyCache::Data::name(), QAxEventSink::OnChanged(), QDeclarativeBindingCompilerPrivate::parseName(), QDeclarativeValueTypeScriptClass::property(), QDeclarativeProperty::property(), QDeclarativeObjectScriptClass::property(), QObject::property(), QAxBase::propertyBag(), QDeclarativeEngineDebugService::propertyData(), QDeclarativeObjectScriptClass::propertyNames(), QDeclarativeProperty::propertyTypeName(), QScript::QObjectDelegate::put(), qax_generateDocumentation(), qax_noSuchFunction(), qDBusPropertyGet(), QDBusAbstractInterfaceBase::qt_metacall(), QAxBase::qt_metacall(), QDeclarativeValueTypeScriptClass::queryProperty(), readAllProperties(), QDeclarativePropertyPrivate::readValueProperty(), QDeclarativeCompiledBindingsPrivate::run(), QAxServerBase::Save(), QDeclarativePropertyPrivate::saveProperty(), QDeclarativePropertyPrivate::saveValueType(), QStyleSheetStyle::setProperties(), QDeclarativeValueTypeScriptClass::setProperty(), QObject::setProperty(), QAxBase::setPropertyBag(), QDeclarativeQtScriptExpression::updateGuards(), QPropertyAnimationPrivate::updateMetaProperty(), userProperty(), and writeProperty().

872 {
873  int i = index;
874  i -= propertyOffset();
875  if (i < 0 && d.superdata)
876  return d.superdata->property(index);
877 
878  QMetaProperty result;
879  if (i >= 0 && i < priv(d.data)->propertyCount) {
880  int handle = priv(d.data)->propertyData + 3*i;
881  int flags = d.data[handle + 2];
882  const char *type = d.stringdata + d.data[handle + 1];
883  result.mobj = this;
884  result.handle = handle;
885  result.idx = i;
886 
887  if (flags & EnumOrFlag) {
888  result.menum = enumerator(indexOfEnumerator(type));
889  if (!result.menum.isValid()) {
890  QByteArray enum_name = type;
891  QByteArray scope_name = d.stringdata;
892  int s = enum_name.lastIndexOf("::");
893  if (s > 0) {
894  scope_name = enum_name.left(s);
895  enum_name = enum_name.mid(s + 2);
896  }
897  const QMetaObject *scope = 0;
898  if (scope_name == "Qt")
900  else
901  scope = QMetaObject_findMetaObject(this, scope_name);
902  if (scope)
903  result.menum = scope->enumerator(scope->indexOfEnumerator(enum_name));
904  }
905  }
906  }
907  return result;
908 }
The QMetaObject class contains meta-information about Qt objects.
Definition: qobjectdefs.h:304
int type
Definition: qmetatype.cpp:239
bool isValid() const
Returns true if this enum is valid (has a name); otherwise returns false.
Definition: qmetaobject.h:168
The QByteArray class provides an array of bytes.
Definition: qbytearray.h:135
int lastIndexOf(char c, int from=-1) const
Returns the index position of the last occurrence of character ch in the byte array, searching backward from index position from.
QByteArray left(int len) const
Returns a byte array that contains the leftmost len bytes of this byte array.
QByteArray mid(int index, int len=-1) const
Returns a byte array containing len bytes from this byte array, starting at position pos...
static const QMetaObject * QMetaObject_findMetaObject(const QMetaObject *self, const char *name)
static const QMetaObjectPrivate * priv(const uint *data)
struct QMetaObject::@38 d
QMetaEnum enumerator(int index) const
Returns the meta-data for the enumerator with the given index.
static const QMetaObject staticQtMetaObject
Definition: qobject.h:322
quint16 index
QMetaEnum menum
Definition: qmetaobject.h:220
The QMetaProperty class provides meta-data about a property.
Definition: qmetaobject.h:176
int propertyOffset() const
Returns the property offset for this class; i.e.
int indexOfEnumerator(const char *name) const
Finds enumerator name and returns its index; otherwise returns -1.
const QMetaObject * mobj
Definition: qmetaobject.h:217

◆ propertyCount()

int QMetaObject::propertyCount ( ) const

Returns the number of properties in this class, including the number of properties provided by each base class.

Use code like the following to obtain a QStringList containing the properties specific to a given class:

const QMetaObject* metaObject = obj->metaObject();
for(int i = metaObject->propertyOffset(); i < metaObject->propertyCount(); ++i)
properties << QString::fromLatin1(metaObject->property(i).name());
See also
property(), propertyOffset(), indexOfProperty()

Definition at line 503 of file qmetaobject.cpp.

Referenced by QMetaObjectBuilder::addMetaObject(), QDeclarativePropertyCache::append(), classIDL(), clone(), generateInterfaceXml(), QScript::QObjectDelegate::getOwnPropertyNames(), QAxServerBase::GetSizeMax(), QDeclarativeTypePrivate::init(), QAxBase::internalProperty(), QAxServerBase::Load(), QDeclarativeVMEMetaObject::metaCall(), QAxBase::propertyBag(), QDeclarativeObjectScriptClass::propertyNames(), qax_generateDocumentation(), qax_noSuchFunction(), qDBusGenerateMetaObjectXml(), QAxBase::qt_metacall(), readAllProperties(), QDeclarativeVMEMetaObject::registerInterceptor(), QAxServerBase::Save(), QDeclarativeData::setBindingBit(), QAxBase::setPropertyBag(), QDeclarativePropertyCache::update(), userProperty(), and QDeclarativeValueTypeFactory::valueType().

504 {
505  int n = priv(d.data)->propertyCount;
506  const QMetaObject *m = d.superdata;
507  while (m) {
508  n += priv(m->d.data)->propertyCount;
509  m = m->d.superdata;
510  }
511  return n;
512 }
The QMetaObject class contains meta-information about Qt objects.
Definition: qobjectdefs.h:304
const uint * data
Definition: qobjectdefs.h:471
const QMetaObject * superdata
Definition: qobjectdefs.h:469
static const QMetaObjectPrivate * priv(const uint *data)
struct QMetaObject::@38 d

◆ propertyOffset()

int QMetaObject::propertyOffset ( ) const

Returns the property offset for this class; i.e.

the index position of this class's first property.

The offset is the sum of all the properties in the class's superclasses (which is always positive since QObject has the name() property).

See also
property(), propertyCount(), indexOfProperty()

Definition at line 403 of file qmetaobject.cpp.

Referenced by QDeclarativeFastProperties::accessorIndexForProperty(), QDeclarativeFastProperties::add(), QMetaObjectBuilder::addMetaObject(), QDeclarativePropertyCache::append(), classIDL(), clone(), QDeclarativePropertyCache::create(), QScript::QObjectDelegate::deleteProperty(), QDeclarativeCompiler::genObject(), QScript::QObjectDelegate::getOwnPropertyDescriptor(), QScript::QObjectDelegate::getOwnPropertyNames(), QScript::QObjectDelegate::getOwnPropertySlot(), indexOfProperty(), QDeclarativeTypePrivate::init(), QAxBase::internalProperty(), QMetaProperty::isDesignable(), QMetaProperty::isScriptable(), QMetaProperty::isStored(), QMetaProperty::isUser(), QDeclarativeProxyMetaObject::metaCall(), QDeclarativePropertyPrivate::metaObjectForProperty(), property(), QAxBase::propertyBag(), QMetaProperty::propertyIndex(), QDeclarativeObjectScriptClass::propertyNames(), QScript::QObjectDelegate::put(), qax_noSuchFunction(), QDeclarativeVMEMetaObject::QDeclarativeVMEMetaObject(), QAxBase::qt_metacall(), QMetaProperty::read(), QMetaProperty::reset(), QAxBase::setPropertyBag(), and QMetaProperty::write().

404 {
405  int offset = 0;
406  const QMetaObject *m = d.superdata;
407  while (m) {
408  offset += priv(m->d.data)->propertyCount;
409  m = m->d.superdata;
410  }
411  return offset;
412 }
The QMetaObject class contains meta-information about Qt objects.
Definition: qobjectdefs.h:304
const uint * data
Definition: qobjectdefs.h:471
const QMetaObject * superdata
Definition: qobjectdefs.h:469
static const QMetaObjectPrivate * priv(const uint *data)
struct QMetaObject::@38 d

◆ removeGuard()

void QMetaObject::removeGuard ( QObject **  ptr)
static
Warning
This function is not part of the public interface.

Definition at line 406 of file qobject.cpp.

Referenced by QAction::activate(), and QPointer< QAbstractButton >::~QPointer().

407 {
408  if (!*ptr)
409  return;
410  GuardHash *hash = guardHash();
411  /* check that the hash is empty - otherwise we might detach
412  the shared_null hash, which will alloc, which is not nice */
413  if (!hash || hash->isEmpty())
414  return;
415  QMutexLocker locker(guardHashLock());
416  if (!*ptr) //check again, under the lock
417  return;
418  GuardHash::iterator it = hash->find(*ptr);
419  const GuardHash::iterator end = hash->end();
420  bool more = false; //if the QObject has more pointer attached to it.
421  for (; it.key() == *ptr && it != end; ++it) {
422  if (it.value() == ptr) {
423  it = hash->erase(it);
424  if (!more) more = (it != end && it.key() == *ptr);
425  break;
426  }
427  more = true;
428  }
429  if (!more)
430  QObjectPrivate::get(*ptr)->hasGuards = false;
431 }
The QMultiHash class is a convenience QHash subclass that provides multi-valued hashes.
Definition: qcontainerfwd.h:58
static uint hash(const uchar *p, int n)
Definition: qhash.cpp:68
#define it(className, varName)
uint hasGuards
Definition: qobject.h:104
T & value() const
Returns a modifiable reference to the current item&#39;s value.
Definition: qhash.h:348
static QObjectPrivate * get(QObject *o)
Definition: qobject_p.h:177
QHash< Key, T >::iterator find(const Key &key, const T &value)
Returns an iterator pointing to the item with the key and value.
Definition: qhash.h:972
bool isEmpty() const
Returns true if the hash contains no items; otherwise returns false.
Definition: qhash.h:297
const T * ptr(const T &t)
const Key & key() const
Returns the current item&#39;s key as a const reference.
Definition: qhash.h:347
The QMutexLocker class is a convenience class that simplifies locking and unlocking mutexes...
Definition: qmutex.h:101
iterator end()
Returns an STL-style iterator pointing to the imaginary item after the last item in the hash...
Definition: qhash.h:467
The QHash::iterator class provides an STL-style non-const iterator for QHash and QMultiHash.
Definition: qhash.h:330
static const KeyPair *const end
iterator erase(iterator it)
Removes the (key, value) pair associated with the iterator pos from the hash, and returns an iterator...
Definition: qhash.h:827

◆ static_metacall()

int QMetaObject::static_metacall ( Call  cl,
int  idx,
void **  argv 
) const
Warning
This function is not part of the public interface.

Definition at line 228 of file qmetaobject.cpp.

Referenced by QScript::callQtMethod(), and newInstance().

229 {
230  const QMetaObjectExtraData *extra = reinterpret_cast<const QMetaObjectExtraData *>(d.extradata);
231  if (priv(d.data)->revision >= 6) {
232  if (!extra || !extra->static_metacall)
233  return 0;
234  extra->static_metacall(0, cl, idx, argv);
235  return -1;
236  } else if (priv(d.data)->revision >= 2) {
237  if (!extra || !extra->static_metacall)
238  return 0;
239  typedef int (*OldMetacall)(QMetaObject::Call, int, void **);
240  OldMetacall o = reinterpret_cast<OldMetacall>(extra->static_metacall);
241  return o(cl, idx, argv);
242  }
243  return 0;
244 }
StaticMetacallFunction static_metacall
Definition: qobjectdefs.h:488
static const QMetaObjectPrivate * priv(const uint *data)
struct QMetaObject::@38 d

◆ superClass()

const QMetaObject * QMetaObject::superClass ( ) const
inline

◆ tr() [1/2]

QString QMetaObject::tr ( const char *  s,
const char *  c 
) const
Warning
This function is not part of the public interface.

Definition at line 320 of file qmetaobject.cpp.

321 {
323 }
unsigned char c[8]
Definition: qnumeric_p.h:62
static QString translate(const char *context, const char *key, const char *disambiguation=0, Encoding encoding=CodecForTr)
struct QMetaObject::@38 d

◆ tr() [2/2]

QString QMetaObject::tr ( const char *  s,
const char *  c,
int  n 
) const
Warning
This function is not part of the public interface.

Definition at line 328 of file qmetaobject.cpp.

329 {
330  return QCoreApplication::translate(d.stringdata, s, c, QCoreApplication::CodecForTr, n);
331 }
unsigned char c[8]
Definition: qnumeric_p.h:62
static QString translate(const char *context, const char *key, const char *disambiguation=0, Encoding encoding=CodecForTr)
struct QMetaObject::@38 d

◆ trUtf8() [1/2]

QString QMetaObject::trUtf8 ( const char *  s,
const char *  c 
) const
Warning
This function is not part of the public interface.

Definition at line 336 of file qmetaobject.cpp.

337 {
339 }
unsigned char c[8]
Definition: qnumeric_p.h:62
static QString translate(const char *context, const char *key, const char *disambiguation=0, Encoding encoding=CodecForTr)
struct QMetaObject::@38 d

◆ trUtf8() [2/2]

QString QMetaObject::trUtf8 ( const char *  s,
const char *  c,
int  n 
) const
Warning
This function is not part of the public interface.

Definition at line 344 of file qmetaobject.cpp.

345 {
347 }
unsigned char c[8]
Definition: qnumeric_p.h:62
static QString translate(const char *context, const char *key, const char *disambiguation=0, Encoding encoding=CodecForTr)
struct QMetaObject::@38 d

◆ userProperty()

QMetaProperty QMetaObject::userProperty ( ) const

Returns the property that has the USER flag set to true.

Since
4.2
See also
QMetaProperty::isUser()

Definition at line 920 of file qmetaobject.cpp.

Referenced by QDataWidgetMapper::mappedPropertyName(), QStyledItemDelegate::setEditorData(), QItemDelegate::setEditorData(), QStyledItemDelegate::setModelData(), and QItemDelegate::setModelData().

921 {
922  const int propCount = propertyCount();
923  for (int i = propCount - 1; i >= 0; --i) {
924  const QMetaProperty prop = property(i);
925  if (prop.isUser())
926  return prop;
927  }
928  return QMetaProperty();
929 }
bool isUser(const QObject *obj=0) const
Returns true if this property is designated as the USER property, i.e., the one that the user can edi...
int propertyCount() const
Returns the number of properties in this class, including the number of properties provided by each b...
The QMetaProperty class provides meta-data about a property.
Definition: qmetaobject.h:176
QMetaProperty property(int index) const
Returns the meta-data for the property with the given index.

Properties

◆ d

struct { ... } QMetaObject::d

Referenced by QMetaObjectBuilder::addMetaObject(), QDeclarativeVMEMetaObject::aliasTarget(), buildMetaObject(), cast(), classInfo(), classInfoCount(), classInfoOffset(), QAxBase::clear(), computeOffsets(), QMetaObjectPrivate::connect(), QDeclarativeVMEMetaObject::connectAlias(), constructor(), constructorCount(), QAxBase::control(), QDeclarativeItemPrivate::data_append(), QAxBase::disableClassInfo(), QAxBase::disableEventSink(), QAxBase::disableMetaObject(), enumerator(), enumeratorCount(), enumeratorOffset(), QDeclarativePropertyPrivate::equal(), flush_vme_signal(), QMetaObjectBuilder::fromRelocatableData(), QMetaProperty::hasNotifySignal(), QMetaProperty::hasStdCppSet(), indexOfClassInfo(), indexOfConstructor(), indexOfEnumerator(), indexOfMethodRelative(), indexOfProperty(), QMetaObjectPrivate::indexOfSignalRelative(), QAxBase::indexOfVerb(), QDeclarativeTypePrivate::init(), QAxBase::initialize(), QAxBase::initializeFrom(), QAxBase::initializeRemote(), QAxBase::internalMetaObject(), QAxBase::internalRelease(), QMetaProperty::isDesignable(), QMetaProperty::isEnumType(), QMetaProperty::isReadable(), QMetaProperty::isResettable(), QMetaProperty::isScriptable(), QMetaProperty::isStored(), QMetaProperty::isUser(), QMetaProperty::isWritable(), QMetaObjectPrivate::memberIndexes(), QDeclarativeVMEMetaObject::metaCall(), MetaObjectGenerator::metaObject(), QDeclarativePropertyPrivate::metaObjectForProperty(), method(), methodCount(), methodOffset(), QMetaProperty::name(), normalizedSignature(), QMetaProperty::notifySignalIndex(), QDeclarativeParser::Object::Object(), property(), propertyCount(), propertyOffset(), QAxBase::QAxBase(), QAxMetaObject::QAxMetaObject(), QDeclarativeVMEMetaObject::QDeclarativeVMEMetaObject(), QMetaObject_findMetaObject(), QMetaObject_methods(), QMetaObject_properties(), qNormalizeType(), QAxBase::queryInterface(), QMetaProperty::read(), QMetaProperty::revision(), QAxBase::setControl(), static_metacall(), tr(), trUtf8(), QMetaProperty::type(), QMetaProperty::typeName(), QAxBase::verbs(), QDBusMetaObjectGenerator::write(), QMetaProperty::write(), QAxBase::~QAxBase(), and QAxMetaObject::~QAxMetaObject().

◆ data

const uint* QMetaObject::data

◆ extradata

const void* QMetaObject::extradata

◆ stringdata

const char* QMetaObject::stringdata

◆ superdata

const QMetaObject* QMetaObject::superdata

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