Source Code (Use browser search to find items of interest.)
Class Index
qt'QObject (./qt-2.1.0/src/kernel/qobject.h:44)
class Q_EXPORT QObject: public Qt
{
Q_PROPERTY( QCString name READ name WRITE setName )
public:
QObject( QObject *parent=0, const char *name=0 );
virtual ~QObject();
static QString tr(const char*);
virtual bool event( QEvent * );
virtual bool eventFilter( QObject *, QEvent * );
virtual QMetaObject *metaObject() const { return staticMetaObject(); }
virtual const char *className() const;
bool isA( const char * ) const;
bool inherits( const char * ) const;
const char *name() const;
const char *name( const char * defaultName ) const;
virtual void setName( const char *name );
bool isWidgetType() const { return isWidget; }
bool highPriority() const { return FALSE; }
bool signalsBlocked() const { return blockSig; }
void blockSignals( bool b );
int startTimer( int interval );
void killTimer( int id );
void killTimers();
QObject *child( const char *name, const char *type = 0 );
const QObjectList *children() const { return childObjects; }
static const QObjectList *objectTrees();
QObjectList *queryList( const char *inheritsClass = 0,
const char *objName = 0,
bool regexpMatch = TRUE,
bool recursiveSearch = TRUE ); //### const in 3.0
virtual void insertChild( QObject * );
virtual void removeChild( QObject * );
void installEventFilter( const QObject * );
void removeEventFilter( const QObject * );
static bool connect( const QObject *sender, const char *signal,
const QObject *receiver, const char *member );
bool connect( const QObject *sender, const char *signal,
const char *member ) const;
static bool disconnect( const QObject *sender, const char *signal,
const QObject *receiver, const char *member );
bool disconnect( const char *signal=0,
const QObject *receiver=0, const char *member=0 );
bool disconnect( const QObject *receiver, const char *member=0 );
void dumpObjectTree();
void dumpObjectInfo();
bool setProperty( const char *name, const QVariant& value ); // virtual in Qt 3.0
QVariant property( const char *name ) const; // virtual in Qt 3.0
signals:
void destroyed();
public:
QObject *parent() const { return parentObj; }
private slots:
void cleanupEventFilter();
protected:
bool activate_filters( QEvent * );
QConnectionList *receivers( const char *signal ) const;
void activate_signal( const char *signal );
void activate_signal( const char *signal, short );
void activate_signal( const char *signal, int );
void activate_signal( const char *signal, long );
void activate_signal( const char *signal, const char * );
void activate_signal_bool( const char *signal, bool );
void activate_signal_string( const char *signal, QString );
void activate_signal_strref( const char *signal, const QString & );
const QObject *sender();
virtual void initMetaObject();
static QMetaObject* staticMetaObject();
virtual void timerEvent( QTimerEvent * );
virtual void childEvent( QChildEvent * );
virtual void connectNotify( const char *signal );
virtual void disconnectNotify( const char *signal );
virtual bool checkConnectArgs( const char *signal, const QObject *receiver,
const char *member );
static void badSuperclassWarning( const char *className,
const char *superclassName );
private:
uint isSignal : 1;
uint isWidget : 1;
uint pendTimer : 1;
uint pendEvent : 1;
uint blockSig : 1;
uint wasDeleted : 1;
uint isTree : 1;
QMetaObject *queryMetaObject() const;
static QMetaObject *metaObj;
const char *objname;
QObject *parentObj;
QObjectList *childObjects;
QSignalDict *connections;
QObjectList *senderObjects;
QObjectList *eventFilters;
QObject *sigSender;
friend class QApplication;
friend class QBaseApplication;
friend class QWidget;
friend class QSignal;
friend class QSenderObject;
private: // Disabled copy constructor and operator=
#if defined(Q_DISABLE_COPY)
QObject( const QObject & );
QObject &operator=( const QObject & );
#endif
public:
// obsolete
QStringList superClasses( bool includeThis = FALSE ) const; // obsolete, remove 3.0
};
inline bool QObject::connect( const QObject *sender, const char *signal,
const char *member ) const
{
return connect( sender, signal, this, member );
}
inline bool QObject::disconnect( const char *signal,
const QObject *receiver, const char *member )
{
return disconnect( this, signal, receiver, member );
}
inline bool QObject::disconnect( const QObject *receiver, const char *member )
{
return disconnect( this, 0, receiver, member );
}
inline const QObject *QObject::sender()
{
return sigSender;
}
qt'QObject::sender() (./qt-2.1.0/include/qobject.h:201)
inline const QObject *QObject::sender()
{
return sigSender;
}
qt'QObject::QObject() (./qt-2.1.0/src/kernel/qobject.cpp:308)
QObject::QObject( QObject *parent, const char *name )
{
if ( !objectDict ) // will create object dict
initMetaObject();
objname = name ? qstrdup(name) : 0; // set object name
childObjects = 0; // no children yet
connections = 0; // no connections yet
senderObjects = 0; // no signals connected yet
eventFilters = 0; // no filters installed
sigSender = 0; // no sender yet
isSignal = FALSE; // assume not a signal object
isWidget = FALSE; // assume not a widget object
pendTimer = FALSE; // no timers yet
pendEvent = FALSE; // no events yet
blockSig = FALSE; // not blocking signals
wasDeleted = FALSE; // double-delete catcher
isTree = FALSE; // no tree yet
parentObj = parent; // to avoid root checking in insertChild()
if ( parent ) { // add object to parent
parent->insertChild( this );
} else {
insert_tree( this );
isTree = TRUE;
}
}
/*!
Destructs the object, deleting all its child objects.
All signals to and from the object are automatically disconnected.
\warning \e All child objects are deleted. If any of these objects are
on the stack or global, your program will sooner or later crash. We do
not recommend holding pointers to child objects from outside the parent.
If you still do, the QObject::destroyed() signal gives you an
opportunity to detect when an object is destroyed.
*/
qt'QObject::~QObject() (./qt-2.1.0/src/kernel/qobject.cpp:348)
QObject::~QObject()
{
if ( wasDeleted ) {
#if defined(DEBUG)
qWarning( "Double QObject deletion detected." );
#endif
return;
}
wasDeleted = 1;
emit destroyed();
if ( objname )
delete [] (char*)objname;
objname = 0;
if ( pendTimer ) // might be pending timers
qKillTimer( this );
if ( pendEvent )
QApplication::removePostedEvents( this );
if ( isTree ) {
remove_tree( this ); // remove from global root list
isTree = FALSE;
}
if ( parentObj ) // remove it from parent object
parentObj->removeChild( this );
register QObject *obj;
if ( senderObjects ) { // disconnect from senders
QObjectList *tmp = senderObjects;
senderObjects = 0;
obj = tmp->first();
while ( obj ) { // for all senders...
obj->disconnect( this );
obj = tmp->next();
}
delete tmp;
}
if ( connections ) { // disconnect receivers
QSignalDictIt it(*connections);
QConnectionList *clist;
while ( (clist=it.current()) ) { // for each signal...
++it;
register QConnection *c;
QConnectionListIt cit(*clist);
while( (c=cit.current()) ) { // for each connected slot...
++cit;
if ( (obj=c->object()) )
removeObjFromList( obj->senderObjects, this );
}
}
delete connections;
connections = 0;
}
if ( eventFilters ) {
delete eventFilters;
eventFilters = 0;
}
if ( childObjects ) { // delete children objects
QObjectListIt it(*childObjects);
while ( (obj=it.current()) ) {
++it;
obj->parentObj = 0;
// ### nest line is a QGList workaround - remove in 3.0
childObjects->removeRef( obj );
delete obj;
}
delete childObjects;
}
}
/*!
\fn QMetaObject *QObject::metaObject() const
Returns a pointer to the meta object of this object.
A meta object contains information about a class that inherits
QObject: class name, super class name, properties, signals and
slots. Every class that contains the \c Q_OBJECT macro will also
have a meta object.
The meta object information is required by the signal/slot
connection mechanism and the property system. The functions isA()
and inherits() also make use of the meta object.
*/
/*!
Returns the class name of this object.
This function is generated by the \link metaobjects.html Meta Object
Compiler. \endlink
\warning This function will return an invalid name if the class
definition lacks the \c Q_OBJECT macro.
\sa name(), inherits(), isA(), isWidgetType()
*/
qt'QObject::className() (./qt-2.1.0/src/kernel/qobject.cpp:442)
const char *QObject::className() const
{
return "QObject";
}
/*!
Returns TRUE if this object is an instance of a specified class,
otherwise FALSE.
Example:
\code
QTimer *t = new QTimer; // QTimer inherits QObject
t->isA("QTimer"); // returns TRUE
t->isA("QObject"); // returns FALSE
\endcode
\sa inherits(), metaObject()
*/
qt'QObject::isA() (./qt-2.1.0/src/kernel/qobject.cpp:462)
bool QObject::isA( const char *clname ) const
{
QMetaObject *meta = queryMetaObject();
return meta ? strcmp(clname,meta->className()) == 0 : FALSE;
}
/*!
Returns TRUE if this object is an instance of a class that inherits
\e clname, and \a clname inherits QObject.
(A class is considered to inherit itself.)
Example:
\code
QTimer *t = new QTimer; // QTimer inherits QObject
t->inherits("QTimer"); // returns TRUE
t->inherits("QObject"); // returns TRUE
t->inherits("QButton"); // returns FALSE
QScrollBar * s = new QScrollBar; // inherits QWidget and QRangeControl
s->inherits( "QWidget" ); // returns TRUE
s->inherits( "QRangeControl" ); // returns FALSE
\endcode
\sa isA(), metaObject()
*/
qt'QObject::inherits() (./qt-2.1.0/src/kernel/qobject.cpp:489)
bool QObject::inherits( const char *clname ) const
{
QMetaObject *meta = queryMetaObject();
return meta? meta->inherits( clname ) : FALSE;
}
#if QT_VERSION >= 290
#error "remove superClasses now."
#endif
/*! \obsolete
This function is misleadingly named, and cannot be implemented in a
way that fulfils its name. someQWidget->superClasses() should have
returned QPaintDevice and QObject, obviously. And it never can, so
let us kill the function. <strong>It will be removed in Qt-3.0</strong>
Oh, and the return type was wrong, too. QStringList not QStrList.
*/
qt'QObject::superClasses() (./qt-2.1.0/src/kernel/qobject.cpp:510)
QStringList QObject::superClasses( bool includeThis ) const
{
qObsolete( "QObject", "superClasses" ); // Arnt killed it. RIP.
QStringList lst;
QMetaObject *meta = queryMetaObject();
if ( meta ) {
if ( !includeThis )
meta = meta->superClass();
while ( meta ) {
lst.append( QString::fromLatin1(meta->className()) );
meta = meta->superClass();
}
}
return lst;
}
/*!
\fn const char *QObject::name() const
Returns the name of this object. If the object does not have a name,
it will return "unnamed", so that printf() (used in qDebug()) will
not be asked to output a null pointer. If you want a null pointer
to be returned for unnamed objects, you can call name( 0 ).
\code
qDebug( "MyClass::setPrecision(): (%s) unable to set precision to %f",
name(), newPrecision );
\endcode
The object name is set by the constructor or by the setName()
function. The object name is not very useful in the current version
of Qt, but will become increasingly important in the future.
The queryList() function searches the object tree for objects that
matches a particular object name.
\sa setName(), className(), queryList()
*/
qt'QObject::name() (./qt-2.1.0/src/kernel/qobject.cpp:551)
const char * QObject::name() const
{
// If you change the name here, the builder will be broken
return objname ? objname : "unnamed";
}
/*!
Returns the name of this object, or \a defaultName if the object
does not have a name.
*/
qt'QObject::name() (./qt-2.1.0/src/kernel/qobject.cpp:562)
const char * QObject::name( const char * defaultName ) const
{
return objname ? objname : defaultName;
}
/*!
Sets the name of this object to \e name. The default name is the
one assigned by the constructor.
The object name is not very useful in the current version of Qt, but
it will become increasingly important in the future.
The queryList() function searches the object tree for objects that
matches a particular object name.
\sa name(), className(), queryList()
*/
qt'QObject::setName() (./qt-2.1.0/src/kernel/qobject.cpp:581)
void QObject::setName( const char *name )
{
if ( objname )
delete [] (char*) objname;
objname = name ? qstrdup(name) : 0;
}
/*!
Returns the pointer to a child widget with the required name and type or
0 if no child matches. This function works recursive. That means it traverses
the entire object tree to find the child. That in turn means that names have
to be unique with regard to their toplevel window.
If multiple widgets with the same name and type are found then it is undefined
which one of them is returned.
If \e type is set to 0 then the only criterion is the object's name.
This function is useful if you need a widget of a dialog that was created from a ressource file.
*/
qt'QObject::child() (./qt-2.1.0/src/kernel/qobject.cpp:602)
QObject* QObject::child( const char *name, const char *type )
{
const QObjectList *list = children();
if ( list ) {
QObjectListIt it( *list );
QObject *obj;
while ( ( obj = it.current() ) ) {
++it;
if ( ( !type || obj->inherits(type) ) && ( !name || qstrcmp( name, obj->name() ) == 0 ) )
return obj;
}
// Recursion: Ask our children ...
QObjectListIt it2( *list );
while ( ( obj = it2.current() ) ) {
++it2;
QObject* o = obj->child( name, type );
if ( o )
return o;
}
}
return 0;
}
/*!
\fn bool QObject::isWidgetType() const
Returns TRUE if the object is a widget, or FALSE if not.
Calling this function is equivalent to calling inherits("QWidget"),
except that it is much faster.
*/
/*!
\fn bool QObject::highPriority() const
Returns TRUE if the object is a high priority object, or FALSE if it is a
standard priority object.
High priority objects are placed first in list of children,
on the assumption that they will be referenced very often.
*/
/*!
This virtual function receives events to an object and should return
TRUE if the event was recognized and processed.
The event() function can be reimplemented to customize the behavior of
an object.
\sa installEventFilter(), timerEvent(), QApplication::sendEvent(),
QApplication::postEvent(), QWidget::event()
*/
qt'QObject::event() (./qt-2.1.0/src/kernel/qobject.cpp:656)
bool QObject::event( QEvent *e )
{
#if defined(CHECK_NULL)
if ( e == 0 )
qWarning( "QObject::event: Null events are not permitted" );
#endif
if ( eventFilters ) { // try filters
if ( activate_filters(e) ) // stopped by a filter
return TRUE;
}
switch ( e->type() ) {
case QEvent::Timer:
timerEvent( (QTimerEvent*)e );
return TRUE;
case QEvent::ChildInserted: case QEvent::ChildRemoved:
childEvent( (QChildEvent*)e );
return TRUE;
default:
break;
}
return FALSE;
}
/*!
This event handler can be reimplemented in a subclass to receive
timer events for the object.
QTimer provides a higher-level interface to the timer functionality,
and also more general information about timers.
\sa startTimer(), killTimer(), killTimers(), event()
*/
qt'QObject::timerEvent() (./qt-2.1.0/src/kernel/qobject.cpp:689)
void QObject::timerEvent( QTimerEvent * )
{
}
/*!
This event handler can be reimplemented in a subclass to receive
child events.
Child events are sent to objects when children are inserted or removed.
Note that events with QEvent::type() \c QEvent::ChildInserted are
\e posted (with QApplication::postEvent()), to make sure that the
child's construction is completed before this function is called.
If you change state based on \c ChildInserted events, call
QWidget::constPolish(), or do
<code>QApplication::sendPostedEvents( this, QEvent::ChildInserted );</code>
in functions that depend on the state. One notable example is
QWidget::sizeHint().
\sa event(), QChildEvent
*/
qt'QObject::childEvent() (./qt-2.1.0/src/kernel/qobject.cpp:713)
void QObject::childEvent( QChildEvent * )
{
}
/*!
Filters events if this object has been installed as an event filter for
another object.
The reimplementation of this virtual function must return TRUE if the
event should be stopped, or FALSE if the event should be dispatched normally.
\sa installEventFilter()
*/
qt'QObject::eventFilter() (./qt-2.1.0/src/kernel/qobject.cpp:728)
bool QObject::eventFilter( QObject *, QEvent * )
{
return FALSE; // don't do anything with it
}
/*!
\internal
Activates all event filters for this object.
This function is normally called from QObject::event() or QWidget::event().
*/
qt'QObject::activate_filters() (./qt-2.1.0/src/kernel/qobject.cpp:740)
bool QObject::activate_filters( QEvent *e )
{
if ( !eventFilters ) // no event filter
return FALSE;
QObjectListIt it( *eventFilters );
register QObject *obj = it.current();
while ( obj ) { // send to all filters
++it; // until one returns TRUE
if ( obj->eventFilter(this,e) ) {
return TRUE;
}
obj = it.current();
}
return FALSE; // don't do anything with it
}
/*!
\fn bool QObject::signalsBlocked() const
Returns TRUE if signals are blocked, or FALSE if signals are not blocked.
Signals are not blocked by default.
\sa blockSignals()
*/
/*!
Blocks signals if \e block is TRUE, or unblocks signals if \e block is FALSE.
Emitted signals disappear into hyperspace if signals are blocked.
*/
qt'QObject::blockSignals() (./qt-2.1.0/src/kernel/qobject.cpp:770)
void QObject::blockSignals( bool block )
{
blockSig = block;
}
//
// The timer flag hasTimer is set when startTimer is called.
// It is not reset when killing the timer because more than
// one timer might be active.
//
/*!
Starts a timer and returns a timer identifier, or returns zero if
it could not start a timer.
A timer event will occur every \e interval milliseconds until
killTimer() or killTimers() is called. If \e interval is 0, then
the timer event occurs once every time there are no more window system
events to process.
The virtual timerEvent() function is called with the QTimerEvent event
parameter class when a timer event occurs. Reimplement this function to
get timer events.
If multiple timers are running, the QTimerEvent::timerId() can be
used to find out which timer was activated.
Example:
\code
class MyObject : public QObject
{
public:
MyObject( QObject *parent=0, const char *name=0 );
protected:
void timerEvent( QTimerEvent * );
};
MyObject::MyObject( QObject *parent, const char *name )
: QObject( parent, name )
{
startTimer( 50 ); // 50 millisecond timer
startTimer( 1000 ); // 1 second timer
startTimer( 60000 ); // 1 minute timer
}
void MyObject::timerEvent( QTimerEvent *e )
{
qDebug( "timer event, id=%d", e->timerId() );
}
\endcode
There is practically no upper limit for the interval value (more than
one year). The accuracy depends on the underlying operating system.
Windows 95 has 55 millisecond (18.2 times per second) accuracy; other
systems that we have tested (UNIX X11, Windows NT and OS/2) can
handle 1 millisecond intervals.
The QTimer class provides a high-level programming interface with
one-shot timers and timer signals instead of events.
\sa timerEvent(), killTimer(), killTimers()
*/
qt'QObject::startTimer() (./qt-2.1.0/src/kernel/qobject.cpp:834)
int QObject::startTimer( int interval )
{
pendTimer = TRUE; // set timer flag
return qStartTimer( interval, (QObject *)this );
}
/*!
Kills the timer with the identifier \e id.
The timer identifier is returned by startTimer() when a timer event is
started.
\sa timerEvent(), startTimer(), killTimers()
*/
qt'QObject::killTimer() (./qt-2.1.0/src/kernel/qobject.cpp:849)
void QObject::killTimer( int id )
{
qKillTimer( id );
}
/*!
Kills all timers that this object has started.
Note that using this function can cause hard-to-find bugs: It kills
timers started by sub- and superclasses as well as those started by
you, which is often not what you want. Therefore, we recommend
using a QTimer, or perhaps killTimer().
\sa timerEvent(), startTimer(), killTimer()
*/
qt'QObject::killTimers() (./qt-2.1.0/src/kernel/qobject.cpp:865)
void QObject::killTimers()
{
qKillTimer( this );
}
qt'QObject::objectTrees() (./qt-2.1.0/src/kernel/qobject.cpp:939)
const QObjectList *QObject::objectTrees()
{
return object_trees;
}
/*!
Returns a list of child objects found by a query.
The query is specified by:
\arg \a inheritsClass is the name of the base class that an object should
inherit. Any class will be matched if \a inheritsClass is 0.
\arg \a objName is the object name to search for. Any object name will be
matched if \a objName is 0.
\arg \a regexpMatch specifies whether \a objName is a regular expression
(default) or not.
\arg \a recursiveSearch must be \c TRUE (default) if you want to search
the entire object tree, or \c FALSE if you want the search to traverse
just the 1st level child objects of this object.
Example:
\code
//
// Sets a Courier 24 point fonts for all children in myWidget that
// inherit QButton (i.e. QPushButton, QCheckBox, QRadioButton).
//
QObjectList *list = myWidget->queryList( "QButton" );
QObjectListIt it( *list ); // iterate over the buttons
QFont newFont( "Courier", 24 );
QObject * obj;
while ( (obj=it.current()) != 0 ) { // for each found object...
++it;
((QButton*)obj)->setFont( newFont );
}
delete list; // delete the list, not the objects
\endcode
The QObjectList class is defined in the qobjcoll.h header file.
\warning
Delete the list away as soon you have finished using it.
You can get in serious trouble if you for instance try to access
an object that has been deleted.
\sa children(), parent(), inherits(), name(), QRegExp
*/
qt'QObject::queryList() (./qt-2.1.0/src/kernel/qobject.cpp:985)
QObjectList *QObject::queryList( const char *inheritsClass,
const char *objName,
bool regexpMatch,
bool recursiveSearch )
{
QObjectList *list = new QObjectList;
CHECK_PTR( list );
if ( regexpMatch && objName ) { // regexp matching
QRegExp rx(QString::fromLatin1(objName));
objSearch( list, (QObjectList *)children(), inheritsClass,
0, &rx, recursiveSearch );
} else {
objSearch( list, (QObjectList *)children(), inheritsClass,
objName, 0, recursiveSearch );
}
return list;
}
/*!
Returns a list of objects/slot pairs that are connected to the
signal, or 0 if nothing is connected to it.
This function is for internal use.
*/
qt'QObject::receivers() (./qt-2.1.0/src/kernel/qobject.cpp:1010)
QConnectionList *QObject::receivers( const char *signal ) const
{
if ( connections && signal ) {
if ( *signal == '2' ) { // tag == 2, i.e. signal
QCString s = qt_rmWS( signal+1 );
return connections->find( (const char*)s );
} else {
return connections->find( signal );
}
}
return 0;
}
/*!
Inserts an object \e obj into the list of child objects.
\warning This function cannot be used to make a widget a child
widget of another. Child widgets can be created only by setting the
parent widget in the constructor or by calling QWidget::reparent().
\sa removeChild(), QWidget::reparent()
*/
qt'QObject::insertChild() (./qt-2.1.0/src/kernel/qobject.cpp:1034)
void QObject::insertChild( QObject *obj )
{
if ( obj->isTree ) {
remove_tree( obj );
obj->isTree = FALSE;
}
if ( obj->parentObj && obj->parentObj != this ) {
#if defined(CHECK_STATE)
if ( obj->parentObj != this && obj->isWidgetType() )
qWarning( "QObject::insertChild: Cannot reparent a widget, "
"use QWidget::reparent() instead" );
#endif
obj->parentObj->removeChild( obj );
}
if ( !childObjects ) {
childObjects = new QObjectList;
CHECK_PTR( childObjects );
}
#if defined(CHECK_STATE)
else if ( childObjects->findRef(obj) >= 0 ) {
qWarning( "QObject::insertChild: Object %s::%s already in list",
obj->className(), obj->name( "unnamed" ) );
return;
}
#endif
obj->parentObj = this;
childObjects->append( obj );
obj->pendEvent = TRUE;
QChildEvent *e = new QChildEvent( QEvent::ChildInserted, obj );
QApplication::postEvent( this, e );
}
/*!
Removes the child object \e obj from the list of children.
\warning
This function will not remove a child widget from the screen.
It will only remove it from the parent widget's list of children.
\sa insertChild(), QWidget::reparent()
*/
qt'QObject::removeChild() (./qt-2.1.0/src/kernel/qobject.cpp:1078)
void QObject::removeChild( QObject *obj )
{
if ( childObjects && childObjects->removeRef(obj) ) {
obj->parentObj = 0;
if ( !wasDeleted ) {
insert_tree( obj ); // it's a root object now
isTree = TRUE;
}
if ( childObjects->isEmpty() ) {
delete childObjects; // last child removed
childObjects = 0; // reset children list
}
// remove events must be sent, not posted!!!
QChildEvent ce( QEvent::ChildRemoved, obj );
QApplication::sendEvent( this, &ce );
}
}
/*!
Installs an event filter object for this object.
An event filter is an object that receives all events that are sent to
this object. The filter can either stop the event or forward it to this
object. The event filter object receives events via the eventFilter()
function. The eventFilter() function must return TRUE if the event
should be stopped, or FALSE if the event should be dispatched normally.
If multiple event filters are installed for a single object, the
filter that was installed last is activated first.
Example:
\code
#include <qwidget.h>
class MyWidget : public QWidget
{
public:
MyWidget::MyWidget( QWidget *parent=0, const char *name=0 );
protected:
bool eventFilter( QObject *, QEvent * );
};
MyWidget::MyWidget( QWidget *parent, const char *name )
: QWidget( parent, name )
{
if ( parent ) // has a parent widget
parent->installEventFilter( this ); // then install filter
}
bool MyWidget::eventFilter( QObject *o, QEvent *e )
{
if ( e->type() == QEvent::KeyPress ) { // key press
QKeyEvent *k = (QKeyEvent*)e;
qDebug( "Ate key press %d", k->key() );
return TRUE; // eat event
}
return QWidget::eventFilter( o, e ); // standard event processing
}
\endcode
The QAccel class, for example, uses this technique.
\warning
If you delete the receiver object in your eventFilter() function, be
sure to return TRUE. If you return FALSE, Qt sends the event to the
deleted object and the program will crash.
\sa removeEventFilter(), eventFilter(), event()
*/
qt'QObject::installEventFilter() (./qt-2.1.0/src/kernel/qobject.cpp:1150)
void QObject::installEventFilter( const QObject *obj )
{
if ( !eventFilters ) {
eventFilters = new QObjectList;
CHECK_PTR( eventFilters );
}
eventFilters->insert( 0, obj );
connect( obj, SIGNAL(destroyed()), this, SLOT(cleanupEventFilter()) );
}
/*!
Removes an event filter object \e obj from this object.
The request is ignored if such an event filter has not been installed.
All event filters for this object are automatically removed when this
object is destroyed.
It is always safe to remove an event filter, even during event filter
activation (i.e. from the eventFilter() function).
\sa installEventFilter(), eventFilter(), event()
*/
qt'QObject::removeEventFilter() (./qt-2.1.0/src/kernel/qobject.cpp:1173)
void QObject::removeEventFilter( const QObject *obj )
{
if ( eventFilters && eventFilters->removeRef(obj) ) {
if ( eventFilters->isEmpty() ) { // last event filter removed
delete eventFilters;
eventFilters = 0; // reset event filter list
}
disconnect( obj, SIGNAL(destroyed()),
this, SLOT(cleanupEventFilter()) );
}
}
/*****************************************************************************
Signal connection management
*****************************************************************************/
qt'QObject::connectNotify() (./qt-2.1.0/src/kernel/qobject.cpp:1300)
void QObject::connectNotify( const char * )
{
}
/*!
\fn void QObject::disconnectNotify( const char *signal )
This virtual function is called when something has been disconnected from
\e signal in this object.
\warning
This function violates the object-oriented principle of modularity.
However, it might be useful for optimizing access to expensive resources.
\sa disconnect(), connectNotify()
*/
qt'QObject::disconnectNotify() (./qt-2.1.0/src/kernel/qobject.cpp:1317)
void QObject::disconnectNotify( const char * )
{
}
/*!
\fn bool QObject::checkConnectArgs( const char *signal, const QObject *receiver, const char *member )
Returns TRUE if the \e signal and the \e member arguments are compatible,
otherwise FALSE.
\warning
We recommend that you do not reimplement this function but use the default
implementation.
\internal
TRUE: "signal(<anything>)", "member()"
TRUE: "signal(a,b,c)", "member(a,b,c)"
TRUE: "signal(a,b,c)", "member(a,b)", "member(a)" etc.
FALSE: "signal(const a)", "member(a)"
FALSE: "signal(a)", "member(const a)"
FALSE: "signal(a)", "member(b)"
FALSE: "signal(a)", "member(a,b)"
*/
qt'QObject::checkConnectArgs() (./qt-2.1.0/src/kernel/qobject.cpp:1342)
bool QObject::checkConnectArgs( const char *signal,
const QObject *,
const char *member )
{
const char *s1 = signal;
const char *s2 = member;
while ( *s1++ != '(' ) ; // scan to first '('
while ( *s2++ != '(' ) ;
if ( *s2 == ')' || strcmp(s1,s2) == 0 ) // member has no args or
return TRUE; // exact match
int s1len = strlen(s1);
int s2len = strlen(s2);
if ( s2len < s1len && strncmp(s1,s2,s2len-1)==0 && s1[s2len-1]==',' )
return TRUE; // member has less args
return FALSE;
}
/* tmake ignore Q_OBJECT */
/* tmake ignore Q_OBJECT */
/*!
Internal function, called from initMetaObject(). Used to emit a warning
when a class containing the macro Q_OBJECT inherits from a class that
does not contain it.
*/
qt'QObject::badSuperclassWarning() (./qt-2.1.0/src/kernel/qobject.cpp:1369)
void QObject::badSuperclassWarning( const char *className,
const char *superclassName )
{
#if defined(CHECK_NULL)
qWarning(
"%s::initMetaObject(): Warning:\n"
" The class \"%s\" contains the Q_OBJECT macro, but inherits from the\n"
" \"%s\" class, which does not contain the Q_OBJECT macro.\n"
" Signal/slot behavior is undefined.\n",
className, className,
superclassName );
#else
Q_UNUSED( className )
Q_UNUSED( superclassName )
#endif
}
/*!
\overload bool QObject::connect( const QObject *sender, const char *signal, const char *member ) const
Connects \e signal from the \e sender object to \e member in this object.
Equivalent to: <code>QObject::connect(sender, signal, this, member)</code>.
\sa disconnect()
*/
/*!
Connects \e signal from the \e sender object to \e member in object \e
receiver.
You must use the SIGNAL() and SLOT() macros when specifying the \e signal
and the \e member.
Example:
\code
QLabel *label = new QLabel;
QScrollBar *scroll = new QScrollBar;
QObject::connect( scroll, SIGNAL(valueChanged(int)),
label, SLOT(setNum(int)) );
\endcode
This example connects the scroll bar's \link QScrollBar::valueChanged()
valueChanged()\endlink signal to the label's \link QLabel::setNum()
setNum()\endlink slot. It makes the label always display the current
scroll bar value.
A signal can even be connected to another signal, i.e. \e member is
a SIGNAL().
\code
class MyWidget : public QWidget
{
public:
MyWidget();
...
signals:
void aSignal();
...
private:
...
QPushButton *aButton;
};
MyWidget::MyWidget()
{
aButton = new QPushButton( this );
connect( aButton, SIGNAL(clicked()), SIGNAL(aSignal()) );
}
\endcode
In its constructor, MyWidget creates a private button and connects the
\link QButton::clicked() clicked()\endlink signal to relay clicked() to
the outside world. You can achieve the same effect by connecting the
clicked() signal to a private slot and emitting aSignal() in this slot,
but that takes a few lines of extra code and is not quite as clear, of
course.
A signal can be connected to many slots/signals. Many signals can be
connected to one slot.
If a signal is connected to several slots, the slots are activated
in arbitrary order when the signal is emitted.
\sa disconnect()
*/
qt'QObject::connect() (./qt-2.1.0/src/kernel/qobject.cpp:1456)
bool QObject::connect( const QObject *sender, const char *signal,
const QObject *receiver, const char *member )
{
#if defined(CHECK_NULL)
if ( sender == 0 || receiver == 0 || signal == 0 || member == 0 ) {
qWarning( "QObject::connect: Cannot connect %s::%s to %s::%s",
sender ? sender->className() : "(null)",
signal ? signal+1 : "(null)",
receiver ? receiver->className() : "(null)",
member ? member+1 : "(null)" );
return FALSE;
}
#endif
QCString signal_name = qt_rmWS( signal ); // white space stripped
QCString member_name = qt_rmWS( member );
signal = signal_name;
member = member_name;
QMetaObject *smeta = sender->queryMetaObject();
if ( !smeta ) // no meta object
return FALSE;
#if defined(CHECK_RANGE)
if ( !check_signal_macro( sender, signal, "connect", "bind" ) )
return FALSE;
#endif
signal++; // skip member type code
QMetaData *sm;
if ( !(sm=smeta->signal(signal,TRUE)) ) { // no such signal
#if defined(CHECK_RANGE)
err_member_notfound( SIGNAL_CODE, sender, signal, "connect" );
err_info_about_candidates( SIGNAL_CODE, smeta, signal, "connect" );
err_info_about_objects( "connect", sender, receiver );
#endif
return FALSE;
}
signal = sm->name; // use name from meta object
int membcode = member[0] - '0'; // get member code
QObject *s = (QObject *)sender; // we need to change them
QObject *r = (QObject *)receiver; // internally
#if defined(CHECK_RANGE)
if ( !check_member_code( membcode, r, member, "connect" ) )
return FALSE;
#endif
member++; // skip code
QMetaData *rm = 0;
QMetaObject *rmeta = r->queryMetaObject();
if ( !rmeta ) // no meta object
return FALSE;
switch ( membcode ) { // get receiver member
case SLOT_CODE: rm = rmeta->slot( member, TRUE ); break;
case SIGNAL_CODE: rm = rmeta->signal( member, TRUE ); break;
}
if ( !rm ) { // no such member
#if defined(CHECK_RANGE)
err_member_notfound( membcode, r, member, "connect" );
err_info_about_candidates( membcode, rmeta, member, "connect" );
err_info_about_objects( "connect", sender, receiver );
#endif
return FALSE;
}
#if defined(CHECK_RANGE)
if ( !s->checkConnectArgs(signal,receiver,member) )
qWarning( "QObject::connect: Incompatible sender/receiver arguments"
"\n\t%s::%s --> %s::%s",
s->className(), signal,
r->className(), member );
#endif
if ( !s->connections ) { // create connections dict
s->connections = new QSignalDict( 7, TRUE, FALSE );
CHECK_PTR( s->connections );
s->connections->setAutoDelete( TRUE );
}
QConnectionList *clist = s->connections->find( signal );
if ( !clist ) { // create receiver list
clist = new QConnectionList;
CHECK_PTR( clist );
clist->setAutoDelete( TRUE );
s->connections->insert( signal, clist );
}
QConnection *c = new QConnection(r, rm->ptr, rm->name);
CHECK_PTR( c );
clist->append( c );
if ( !r->senderObjects ) { // create list of senders
r->senderObjects = new QObjectList;
CHECK_PTR( r->senderObjects );
}
r->senderObjects->append( s ); // add sender to list
s->connectNotify( signal_name );
return TRUE;
}
/*!
\overload bool QObject::disconnect( const char *signal, const QObject *receiver, const char *member )
Disconnects \e signal from \e member of \e receiver.
A signal-slot connection is removed when either of the objects
involved are destroyed.
*/
/*!
\overload bool QObject::disconnect( const QObject *receiver, const char *member )
Disconnects all signals in this object from \e member of \e receiver.
A signal-slot connection is removed when either of the objects
involved are destroyed.
*/
/*!
Disconnects \e signal in object \e sender from \e member in object \e
receiver.
A signal-slot connection is removed when either of the objects
involved are destroyed.
disconnect() is typically used in three ways, as the following examples
show.
<ol>
<li> Disconnect everything connected to an object's signals:
\code
disconnect( myObject, 0, 0, 0 );
\endcode
equivalent to the non-static overloaded function
\code
myObject->disconnect();
\endcode
<li> Disconnect everything connected to a specific signal:
\code
disconnect( myObject, SIGNAL(mySignal()), 0, 0 );
\endcode
equivalent to the non-static overloaded function
\code
myObject->disconnect( SIGNAL(mySignal()) );
\endcode
<li> Disconnect a specific receiver.
\code
disconnect( myObject, 0, myReceiver, 0 );
\endcode
equivalent to the non-static overloaded function
\code
myObject->disconnect( myReceiver );
\endcode
</ol>
0 may be used as a wildcard, meaning "any signal", "any receiving
object" or "any slot in the receiving object" respectively.
The \e sender may never be 0. (You cannot disconnect signals from
more than one object.)
If \e signal is 0, it disconnects \e receiver and \e member from any
signal. If not, only the specified signal is disconnected.
If \e receiver is 0, it disconnects anything connected to \e signal.
If not, slots in objects other than \e receiver are not disconnected.
If \e member is 0, it disconnects anything that is connected to \e
receiver. If not, only slots named \e member will be disconnected,
and all other slots are left alone. The \e member must be 0 if \e
receiver is left out, so you cannot disconnect a specifically-named
slot on all objects.
\sa connect()
*/
qt'QObject::disconnect() (./qt-2.1.0/src/kernel/qobject.cpp:1627)
bool QObject::disconnect( const QObject *sender, const char *signal,
const QObject *receiver, const char *member )
{
#if defined(CHECK_NULL)
if ( sender == 0 || (receiver == 0 && member != 0) ) {
qWarning( "QObject::disconnect: Unexpected null parameter" );
return FALSE;
}
#endif
if ( !sender->connections ) // no connected signals
return FALSE;
QCString signal_name;
QCString member_name;
QMetaData *rm = 0;
QObject *s = (QObject *)sender;
QObject *r = (QObject *)receiver;
if ( member ) {
member_name = qt_rmWS( member );
member = member_name.data();
int membcode = member[0] - '0';
#if defined(CHECK_RANGE)
if ( !check_member_code( membcode, r, member, "disconnect" ) )
return FALSE;
#endif
member++;
QMetaObject *rmeta = r->queryMetaObject();
if ( !rmeta ) // no meta object
return FALSE;
switch ( membcode ) { // get receiver member
case SLOT_CODE: rm = rmeta->slot( member, TRUE ); break;
case SIGNAL_CODE: rm = rmeta->signal( member, TRUE ); break;
}
if ( !rm ) { // no such member
#if defined(CHECK_RANGE)
err_member_notfound( membcode, r, member, "disconnect" );
err_info_about_candidates( membcode, rmeta, member, "connect" );
err_info_about_objects( "disconnect", sender, receiver );
#endif
return FALSE;
}
}
QConnectionList *clist;
register QConnection *c;
if ( signal == 0 ) { // any/all signals
QSignalDictIt it(*(s->connections));
while ( (clist=it.current()) ) { // for all signals...
// Tricky hack to avoid UTF conversion.
const char *curkey = it.currentKey();
++it;
c = clist->first();
while ( c ) { // for all receivers...
if ( r == 0 ) { // remove all receivers
removeObjFromList( c->object()->senderObjects, s );
c = clist->next();
} else if ( r == c->object() &&
(member == 0 ||
strcmp(member,c->memberName()) == 0) ) {
removeObjFromList( c->object()->senderObjects, s );
clist->remove();
c = clist->current();
} else {
c = clist->next();
}
}
if ( r == 0 ) // disconnect all receivers
s->connections->remove( curkey );
}
s->disconnectNotify( 0 );
}
else { // specific signal
signal_name = qt_rmWS( signal );
signal = signal_name.data();
#if defined(CHECK_RANGE)
if ( !check_signal_macro( s, signal, "disconnect", "unbind" ) )
return FALSE;
#endif
signal++;
clist = s->connections->find( signal );
if ( !clist ) {
#if defined(CHECK_RANGE)
QMetaObject *smeta = s->queryMetaObject();
if ( !smeta ) // no meta object
return FALSE;
if ( !smeta->signal(signal,TRUE) )
qWarning( "QObject::disconnect: No such signal %s::%s",
s->className(), signal );
#endif
return FALSE;
}
c = clist->first();
while ( c ) { // for all receivers...
if ( r == 0 ) { // remove all receivers
removeObjFromList( c->object()->senderObjects, s, TRUE );
c = clist->next();
} else if ( r == c->object() && (member == 0 ||
strcmp(member,c->memberName()) == 0) ) {
removeObjFromList( c->object()->senderObjects, s, TRUE );
clist->remove();
c = clist->current();
} else {
c = clist->next();
}
}
if ( r == 0 ) // disconnect all receivers
s->connections->remove( signal );
s->disconnectNotify( signal_name );
}
return TRUE;
}
/*!
This signal is emitted immediately before the object is destroyed.
All the objects's children are destroyed immediately after this signal
is emitted.
*/
qt'QObject::destroyed() (./qt-2.1.0/src/kernel/qobject.cpp:1747)
void QObject::destroyed()
{
activate_signal( "destroyed()" );
}
/*!
This slot is connected to the destroyed() signal of other objects
that have installed event filters on this object. When the other
object is destroyed, we want to remove its event filter.
*/
qt'QObject::cleanupEventFilter() (./qt-2.1.0/src/kernel/qobject.cpp:1759)
void QObject::cleanupEventFilter()
{
removeEventFilter( sender() );
}
/*!
\internal
Returns the meta object for this object. If necessary, calls
initMetaObject().
\sa metaObject()
*/
qt'QObject::queryMetaObject() (./qt-2.1.0/src/kernel/qobject.cpp:1772)
QMetaObject *QObject::queryMetaObject() const
{
register QObject *x = (QObject *)this; // fake const
QMetaObject *m = x->metaObject();
if ( !m ) { // not meta object
x->initMetaObject(); // then try to create it
m = x->metaObject();
}
#if defined(CHECK_NULL)
if ( !m ) // still no meta object: error
qWarning( "QObject: Object %s::%s has no meta object",
x->className(), x->name( "unnamed" ) );
#endif
return m;
}
/*!
Returns a translated version of \a text, or \a text if there is
no appropriate translated version. All QObject subclasses which use the
\link metaobjects.html Q_OBJECT macro\endlink have an overridden
version of this.
\sa QApplication::translate()
*/
qt'QObject::tr() (./qt-2.1.0/src/kernel/qobject.cpp:1797)
QString QObject::tr( const char *text )
{
if ( qApp )
return qApp->translate( "QObject", text );
else
return QString::fromLatin1(text);
}
/*!
Initializes the \link metaObject() meta object\endlink of this
object. This method is automatically executed on demand.
\sa metaObject()
*/
qt'QObject::initMetaObject() (./qt-2.1.0/src/kernel/qobject.cpp:1810)
void QObject::initMetaObject()
{
staticMetaObject();
}
/*!
The functionality of initMetaObject(), provided as a static function.
*/
qt'QObject::staticMetaObject() (./qt-2.1.0/src/kernel/qobject.cpp:1819)
QMetaObject* QObject::staticMetaObject()
{
if ( metaObj )
return metaObj;
typedef void(QObject::*m1_t0)();
m1_t0 v1_0 = &QObject::cleanupEventFilter;
QMetaData *slot_tbl = new QMetaData[1];
slot_tbl[0].name = "cleanupEventFilter()";
slot_tbl[0].ptr = *((QMember*)&v1_0);
typedef void(QObject::*m2_t0)();
m2_t0 v2_0 = &QObject::destroyed;
QMetaData *signal_tbl = new QMetaData[1];
signal_tbl[0].name = "destroyed()";
signal_tbl[0].ptr = *((QMember*)&v2_0);
QMetaProperty *props_tbl = new QMetaProperty[1];
typedef const char*(QObject::*m3_t0)()const;
typedef void(QObject::*m3_t1)(const char*);
m3_t0 v3_0 = &QObject::name;
m3_t1 v3_1 = &QObject::setName;
props_tbl[0].n = "name";
props_tbl[0].get = *((QMember*)&v3_0);
props_tbl[0].set = *((QMember*)&v3_1);
props_tbl[0].t = "QCString";
props_tbl[0].enumData = 0;
props_tbl[0].gspec = QMetaProperty::ConstCharStar;
props_tbl[0].sspec = QMetaProperty::ConstCharStar;
QMetaEnum* enum_tbl = QMetaObject::new_metaenum( 3 );
enum_tbl[0].name = "Alignment";
enum_tbl[0].count = 8;
enum_tbl[0].set = TRUE;
enum_tbl[0].items = QMetaObject::new_metaenum_item( 8 );
enum_tbl[0].items[0].key = "AlignLeft";
enum_tbl[0].items[0].value = (int) Qt::AlignLeft;
enum_tbl[0].items[1].key = "AlignRight";
enum_tbl[0].items[1].value = (int) Qt::AlignRight;
enum_tbl[0].items[2].key = "AlignHCenter";
enum_tbl[0].items[2].value = (int) Qt::AlignHCenter;
enum_tbl[0].items[3].key = "AlignTop";
enum_tbl[0].items[3].value = (int) Qt::AlignTop;
enum_tbl[0].items[4].key = "AlignBottom";
enum_tbl[0].items[4].value = (int) Qt::AlignBottom;
enum_tbl[0].items[5].key = "AlignVCenter";
enum_tbl[0].items[5].value = (int) Qt::AlignVCenter;
enum_tbl[0].items[6].key = "AlignCenter";
enum_tbl[0].items[6].value = (int) Qt::AlignCenter;
enum_tbl[0].items[7].key = "WordBreak";
enum_tbl[0].items[7].value = (int) Qt::WordBreak;
enum_tbl[1].name = "Orientation";
enum_tbl[1].count = 2;
enum_tbl[1].set = FALSE;
enum_tbl[1].items = QMetaObject::new_metaenum_item( 2 );
enum_tbl[1].items[0].key = "Horizontal";
enum_tbl[1].items[0].value = (int) Qt::Horizontal;
enum_tbl[1].items[1].key = "Vertical";
enum_tbl[1].items[1].value = (int) Qt::Vertical;
enum_tbl[2].name = "TextFormat";
enum_tbl[2].count = 3;
enum_tbl[2].set = FALSE;
enum_tbl[2].items = QMetaObject::new_metaenum_item( 3 );
enum_tbl[2].items[0].key = "PlainText";
enum_tbl[2].items[0].value = (int) Qt::PlainText;
enum_tbl[2].items[1].key = "RichText";
enum_tbl[2].items[1].value = (int) Qt::RichText;
enum_tbl[2].items[2].key = "AutoText";
enum_tbl[2].items[2].value = (int) Qt::AutoText;
metaObj = new QMetaObject( "QObject", "",
slot_tbl, 1,
signal_tbl, 1,
props_tbl, 1,
enum_tbl, 3,
0, 0 );
return metaObj;
}
/*!
\internal
Signal activation with the most frequently used parameter/argument
types. All other combinations are generated by the meta object
compiler.
*/
qt'QObject::activate_signal() (./qt-2.1.0/src/kernel/qobject.cpp:1901)
void QObject::activate_signal( const char *signal )
{
if ( !connections )
return;
QConnectionList *clist = connections->find( signal );
if ( !clist || signalsBlocked() )
return;
typedef void (QObject::*RT)();
typedef RT *PRT;
RT r;
QConnectionListIt it(*clist);
register QConnection *c;
register QObject *object;
while ( (c=it.current()) ) {
++it;
object = c->object();
object->sigSender = this;
r = *((PRT)(c->member()));
(object->*r)();
}
}
/*!
\overload void QObject::activate_signal( const char *signal, short )
*/
/*!
\overload void QObject::activate_signal( const char *signal, int )
*/
/*!
\overload void QObject::activate_signal( const char *signal, long )
*/
/*!
\overload void QObject::activate_signal( const char *signal, const char * )
*/
qt'QObject::dumpObjectTree() (./qt-2.1.0/src/kernel/qobject.cpp:2048)
void QObject::dumpObjectTree()
{
dumpRecursive( 0, this );
}
/*!
Dumps information about signal connections etc. for this object to the
debug output.
This function is useful for debugging. This function does nothing if
the library has been compiled in release mode (i.e without debugging
information).
*/
qt'QObject::dumpObjectInfo() (./qt-2.1.0/src/kernel/qobject.cpp:2062)
void QObject::dumpObjectInfo()
{
#if defined(DEBUG)
qDebug( "OBJECT %s::%s", className(), name( "unnamed" ) );
qDebug( " SIGNALS OUT" );
int n = 0;
if ( connections ) {
QSignalDictIt it(*connections);
QConnectionList *clist;
while ( (clist=it.current()) ) {
qDebug( "\t%s", it.currentKey() );
n++;
++it;
register QConnection *c;
QConnectionListIt cit(*clist);
while ( (c=cit.current()) ) {
++cit;
qDebug( "\t --> %s::%s %s", c->object()->className(),
c->object()->name( "unnamed" ), c->memberName() );
}
}
}
if ( n == 0 )
qDebug( "\t<None>" );
qDebug( " SIGNALS IN" );
n = 0;
if ( senderObjects ) {
QObject *sender = senderObjects->first();
while ( sender ) {
qDebug( "\t%s::%s",
sender->className(), sender->name( "unnamed" ) );
n++;
sender = senderObjects->next();
}
}
if ( n == 0 )
qDebug( "\t<None>" );
#endif
}
/*!
Sets the object's property \a name to \a value.
Returne TRUE is the operation was successful, FALSE otherwise.
Information about all available properties are provided through the
metaObject().
\sa property(), metaObject(), QMetaObject::propertyNames(), QMetaObject::property()
*/
qt'QObject::setProperty() (./qt-2.1.0/src/kernel/qobject.cpp:2113)
bool QObject::setProperty( const char *name, const QVariant& value )
{
if ( !value.isValid() )
return FALSE;
typedef void (QObject::*ProtoConstCharStar)( const char* );
typedef void (QObject::*ProtoString)( QString );
typedef void (QObject::*RProtoString)( const QString&);
typedef void (QObject::*ProtoCString)( QCString );
typedef void (QObject::*RProtoCString)( const QCString&);
typedef void (QObject::*ProtoInt)( int );
typedef void (QObject::*RProtoInt)( const int& );
typedef void (QObject::*ProtoUInt)( uint );
typedef void (QObject::*RProtoUInt)( const uint& );
typedef void (QObject::*ProtoDouble)( double );
typedef void (QObject::*RProtoDouble)( const double& );
typedef void (QObject::*ProtoBool)( bool );
typedef void (QObject::*RProtoBool)( const bool& );
typedef void (QObject::*ProtoFont)( QFont );
typedef void (QObject::*RProtoFont)( const QFont& );
typedef void (QObject::*ProtoPixmap)( QPixmap );
typedef void (QObject::*RProtoPixmap)( const QPixmap& );
typedef void (QObject::*ProtoBrush)( QBrush );
typedef void (QObject::*RProtoBrush)( const QBrush& );
typedef void (QObject::*ProtoRect)( QRect );
typedef void (QObject::*RProtoRect)( const QRect& );
typedef void (QObject::*ProtoSize)( QSize );
typedef void (QObject::*RProtoSize)( const QSize& );
typedef void (QObject::*ProtoColor)( QColor );
typedef void (QObject::*RProtoColor)( const QColor& );
typedef void (QObject::*ProtoPalette)( QPalette );
typedef void (QObject::*RProtoPalette)( const QPalette& );
typedef void (QObject::*ProtoColorGroup)( QColorGroup );
typedef void (QObject::*RProtoColorGroup)( const QColorGroup& );
typedef void (QObject::*ProtoBitmap)( QBitmap );
typedef void (QObject::*RProtoBitmap)( const QBitmap& );
typedef void (QObject::*ProtoRegion)( QRegion );
typedef void (QObject::*RProtoRegion)( const QRegion& );
typedef void (QObject::*ProtoPointArray)( QPointArray );
typedef void (QObject::*RProtoPointArray)( const QPointArray& );
typedef void (QObject::*ProtoIconSet)( QIconSet );
typedef void (QObject::*RProtoIconSet)( const QIconSet& );
typedef void (QObject::*ProtoImage)( QImage );
typedef void (QObject::*RProtoImage)( const QImage& );
typedef void (QObject::*ProtoCursor)( QCursor );
typedef void (QObject::*RProtoCursor)( const QCursor& );
typedef void (QObject::*ProtoPoint)( QPoint );
typedef void (QObject::*RProtoPoint)( const QPoint& );
typedef void (QObject::*ProtoStringList)( QStringList );
typedef void (QObject::*RProtoStringList)( const QStringList& );
typedef void (QObject::*ProtoList)( QValueList<QVariant> );
typedef void (QObject::*RProtoList)( const QValueList<QVariant>& );
typedef void (QObject::*ProtoMap)( QMap<QString,QVariant> );
typedef void (QObject::*RProtoMap)( const QMap<QString,QVariant>& );
QMetaObject* meta = queryMetaObject();
if ( !meta )
return FALSE;
const QMetaProperty* p = meta->property( name, TRUE );
if ( !p )
return FALSE;
if ( p->isEnumType() ) {
int v = 0;
if( value.type() == QVariant::Int ||
value.type() == QVariant::UInt ) {
v = value.toInt();
} else if ( value.type() == QVariant::String ||
value.type() == QVariant::CString ) {
if ( p->isSetType() ) {
QString s = value.toString();
// QStrList does not support split, use QStringList for that.
QStringList l = QStringList::split( '|', s );
QStrList keys;
for ( QStringList::Iterator it = l.begin(); it != l.end(); ++it )
keys.append( (*it).stripWhiteSpace().latin1() );
v = p->keysToValue( keys );
} else {
v = p->keyToValue( value.toCString().data() );
}
} else {
return FALSE;
}
ProtoInt m = (ProtoInt)p->set;
(this->*m)( v );
return TRUE;
}
QVariant::Type type = QVariant::nameToType( p->type() );
if ( !value.canCast( type ) )
return FALSE;
// Some stupid casts in this switch... for #@$!&@ SunPro C++ 5.0 compiler
switch ( type ) {
case QVariant::Invalid:
return FALSE;
case QVariant::Image:
if ( p->sspec == QMetaProperty::Class ) {
ProtoImage m = (ProtoImage)p->set;
(this->*m)( (QImage)(value.toImage()) );
} else if ( p->sspec == QMetaProperty::Reference ) {
RProtoImage m = (RProtoImage)p->set;
(this->*m)( value.toImage() );
} else {
ASSERT( 0 );
}
return TRUE;
case QVariant::Point:
if ( p->sspec == QMetaProperty::Class ) {
ProtoPoint m = (ProtoPoint)p->set;
(this->*m)( value.toPoint() );
} else if ( p->sspec == QMetaProperty::Reference ) {
RProtoPoint m = (RProtoPoint)p->set;
(this->*m)( value.toPoint() );
} else {
ASSERT( 0 );
}
return TRUE;
case QVariant::StringList:
if ( p->sspec == QMetaProperty::Class ) {
ProtoStringList m = (ProtoStringList)p->set;
(this->*m)( (QStringList)value.toStringList() );
} else if ( p->sspec == QMetaProperty::Reference ) {
RProtoStringList m = (RProtoStringList)p->set;
(this->*m)( value.toStringList() );
} else {
ASSERT( 0 );
}
return TRUE;
case QVariant::String:
if ( p->sspec == QMetaProperty::Class ) {
ProtoString m = (ProtoString)p->set;
(this->*m)( (QString)(value.toString()) );
} else if ( p->sspec == QMetaProperty::Reference ) {
RProtoString m = (RProtoString)p->set;
(this->*m)( value.toString() );
} else {
ASSERT( 0 );
}
return TRUE;
case QVariant::CString:
if ( p->sspec == QMetaProperty::Class ) {
ProtoCString m = (ProtoCString)p->set;
(this->*m)( (QCString)(value.toCString()) );
} else if ( p->sspec == QMetaProperty::Reference ) {
RProtoCString m = (RProtoCString)p->set;
(this->*m)( value.toCString() );
} else if ( p->sspec == QMetaProperty::ConstCharStar ) {
ProtoConstCharStar m = (ProtoConstCharStar)p->set;
(this->*m)( value.toCString().data() );
} else {
ASSERT( 0 );
}
return TRUE;
case QVariant::Font:
if ( p->sspec == QMetaProperty::Class ) {
ProtoFont m = (ProtoFont)p->set;
(this->*m)( (QFont)(value.toFont()) );
} else if ( p->sspec == QMetaProperty::Reference ) {
RProtoFont m = (RProtoFont)p->set;
(this->*m)( value.toFont() );
} else {
ASSERT( 0 );
}
return TRUE;
case QVariant::Pixmap:
if ( p->sspec == QMetaProperty::Class ) {
ProtoPixmap m = (ProtoPixmap)p->set;
(this->*m)( (QPixmap)(value.toPixmap()) );
} else if ( p->sspec == QMetaProperty::Reference ) {
RProtoPixmap m = (RProtoPixmap)p->set;
(this->*m)( value.toPixmap() );
} else {
ASSERT( 0 );
}
return TRUE;
case QVariant::Brush:
if ( p->sspec == QMetaProperty::Class ) {
ProtoBrush m = (ProtoBrush)p->set;
(this->*m)( (QBrush)(value.toBrush()) );
} else if ( p->sspec == QMetaProperty::Reference ) {
RProtoBrush m = (RProtoBrush)p->set;
(this->*m)( value.toBrush() );
} else {
ASSERT( 0 );
}
return TRUE;
case QVariant::Rect:
if ( p->sspec == QMetaProperty::Class ) {
ProtoRect m = (ProtoRect)p->set;
(this->*m)( value.toRect() );
} else if ( p->sspec == QMetaProperty::Reference ) {
RProtoRect m = (RProtoRect)p->set;
(this->*m)( value.toRect() );
} else {
ASSERT( 0 );
}
return TRUE;
case QVariant::Size:
if ( p->sspec == QMetaProperty::Class ) {
ProtoSize m = (ProtoSize)p->set;
(this->*m)( value.toSize() );
} else if ( p->sspec == QMetaProperty::Reference ) {
RProtoSize m = (RProtoSize)p->set;
(this->*m)( value.toSize() );
} else {
ASSERT( 0 );
}
return TRUE;
case QVariant::Color:
if ( p->sspec == QMetaProperty::Class ) {
ProtoColor m = (ProtoColor)p->set;
(this->*m)( (QColor)(value.toColor()) );
} else if ( p->sspec == QMetaProperty::Reference ) {
RProtoColor m = (RProtoColor)p->set;
(this->*m)( value.toColor() );
} else {
ASSERT( 0 );
}
return TRUE;
case QVariant::Palette:
if ( p->sspec == QMetaProperty::Class ) {
ProtoPalette m = (ProtoPalette)p->set;
(this->*m)( (QPalette)(value.toPalette()) );
} else if ( p->sspec == QMetaProperty::Reference ) {
RProtoPalette m = (RProtoPalette)p->set;
(this->*m)( value.toPalette() );
} else {
ASSERT( 0 );
}
return TRUE;
case QVariant::ColorGroup:
if ( p->sspec == QMetaProperty::Class ) {
ProtoColorGroup m = (ProtoColorGroup)p->set;
(this->*m)( (QColorGroup)(value.toColorGroup()) );
} else if ( p->sspec == QMetaProperty::Reference ) {
RProtoColorGroup m = (RProtoColorGroup)p->set;
(this->*m)( value.toColorGroup() );
} else {
ASSERT( 0 );
}
return TRUE;
case QVariant::Bitmap:
if ( p->sspec == QMetaProperty::Class ) {
ProtoBitmap m = (ProtoBitmap)p->set;
(this->*m)( (QBitmap)(value.toBitmap()) );
} else if ( p->sspec == QMetaProperty::Reference ) {
RProtoBitmap m = (RProtoBitmap)p->set;
(this->*m)( value.toBitmap() );
} else {
ASSERT( 0 );
}
return TRUE;
case QVariant::Region:
if ( p->sspec == QMetaProperty::Class ) {
ProtoRegion m = (ProtoRegion)p->set;
(this->*m)( (QRegion)(value.toRegion()) );
} else if ( p->sspec == QMetaProperty::Reference ) {
RProtoRegion m = (RProtoRegion)p->set;
(this->*m)( value.toRegion() );
} else {
ASSERT( 0 );
}
return TRUE;
case QVariant::PointArray:
if ( p->sspec == QMetaProperty::Class ) {
ProtoPointArray m = (ProtoPointArray)p->set;
(this->*m)( (QPointArray)(value.toPointArray()) );
} else if ( p->sspec == QMetaProperty::Reference ) {
RProtoPointArray m = (RProtoPointArray)p->set;
(this->*m)( value.toPointArray() );
} else {
ASSERT( 0 );
}
return TRUE;
case QVariant::Cursor:
if ( p->sspec == QMetaProperty::Class ) {
ProtoCursor m = (ProtoCursor)p->set;
(this->*m)( (QCursor)(value.toCursor()) );
} else if ( p->sspec == QMetaProperty::Reference ) {
RProtoCursor m = (RProtoCursor)p->set;
(this->*m)( value.toCursor() );
} else {
ASSERT( 0 );
}
return TRUE;
case QVariant::IconSet:
if ( p->sspec == QMetaProperty::Class ) {
ProtoIconSet m = (ProtoIconSet)p->set;
(this->*m)( (QIconSet)(value.toIconSet()) );
} else if ( p->sspec == QMetaProperty::Reference ) {
RProtoIconSet m = (RProtoIconSet)p->set;
(this->*m)( value.toIconSet() );
} else {
ASSERT( 0 );
}
return TRUE;
case QVariant::Int:
if ( p->sspec == QMetaProperty::Class ) {
ProtoInt m = (ProtoInt)p->set;
(this->*m)( value.toInt() );
} else if ( p->sspec == QMetaProperty::Reference ) {
RProtoInt m = (RProtoInt)p->set;
(this->*m)( value.toInt() );
} else {
ASSERT( 0 );
}
return TRUE;
case QVariant::UInt:
if ( p->sspec == QMetaProperty::Class ) {
ProtoUInt m = (ProtoUInt)p->set;
(this->*m)( value.toUInt() );
} else if ( p->sspec == QMetaProperty::Reference ) {
RProtoUInt m = (RProtoUInt)p->set;
(this->*m)( value.toUInt() );
} else {
ASSERT( 0 );
}
return TRUE;
case QVariant::Double:
if ( p->sspec == QMetaProperty::Class ) {
ProtoDouble m = (ProtoDouble)p->set;
(this->*m)( value.toDouble() );
} else if ( p->sspec == QMetaProperty::Reference ) {
RProtoDouble m = (RProtoDouble)p->set;
(this->*m)( value.toDouble() );
} else {
ASSERT( 0 );
}
return TRUE;
case QVariant::Bool:
if ( p->sspec == QMetaProperty::Class ) {
ProtoBool m = (ProtoBool)p->set;
(this->*m)( value.toBool() );
} else if ( p->sspec == QMetaProperty::Reference ) {
RProtoBool m = (RProtoBool)p->set;
(this->*m)( value.toBool() );
} else {
ASSERT( 0 );
}
return TRUE;
case QVariant::List:
if ( p->sspec == QMetaProperty::Class ) {
ProtoList m = (ProtoList)p->set;
(this->*m)( (QValueList<QVariant>)(value.toList()) );
} else if ( p->sspec == QMetaProperty::Reference ) {
RProtoList m = (RProtoList)p->set;
(this->*m)( value.toList() );
} else {
ASSERT( 0 );
}
return TRUE;
case QVariant::Map:
if ( p->sspec == QMetaProperty::Class ) {
ProtoMap m = (ProtoMap)p->set;
(this->*m)( (QMap<QString, QVariant>)(value.toMap()) );
} else if ( p->sspec == QMetaProperty::Reference ) {
RProtoMap m = (RProtoMap)p->set;
(this->*m)( value.toMap() );
} else {
ASSERT( 0 );
}
return TRUE;
}
return FALSE;
}
/*!
Returns the value of the object's \a name property.
If no such property exists, the returned variant is invalid.
Information about all available properties are provided through the
metaObject().
\sa setProperty(), QVariant::isValid(), metaObject(),
QMetaObject::propertyNames(), QMetaObject::property()
*/
qt'QObject::property() (./qt-2.1.0/src/kernel/qobject.cpp:2544)
QVariant QObject::property( const char *name ) const
{
QVariant value;
typedef const char* (QObject::*ProtoConstCharStar)() const;
typedef QString (QObject::*ProtoString)() const;
typedef const QString* (QObject::*PProtoString)() const;
typedef const QString& (QObject::*RProtoString)() const;
typedef QCString (QObject::*ProtoCString)() const;
typedef const QCString* (QObject::*PProtoCString)() const;
typedef const QCString& (QObject::*RProtoCString)() const;
typedef int (QObject::*ProtoInt)() const;
typedef const int* (QObject::*PProtoInt)() const;
typedef const int& (QObject::*RProtoInt)() const;
typedef uint (QObject::*ProtoUInt)() const;
typedef const uint* (QObject::*PProtoUInt)() const;
typedef const uint& (QObject::*RProtoUInt)() const;
typedef double (QObject::*ProtoDouble)() const;
typedef const double* (QObject::*PProtoDouble)() const;
typedef const double& (QObject::*RProtoDouble)() const;
typedef bool (QObject::*ProtoBool)() const;
typedef const bool* (QObject::*PProtoBool)() const;
typedef const bool& (QObject::*RProtoBool)() const;
typedef QFont (QObject::*ProtoFont)() const;
typedef const QFont* (QObject::*PProtoFont)() const;
typedef const QFont& (QObject::*RProtoFont)() const;
typedef QPixmap (QObject::*ProtoPixmap)() const;
typedef const QPixmap* (QObject::*PProtoPixmap)() const;
typedef const QPixmap& (QObject::*RProtoPixmap)() const;
typedef QBrush (QObject::*ProtoBrush)() const;
typedef const QBrush* (QObject::*PProtoBrush)() const;
typedef const QBrush& (QObject::*RProtoBrush)() const;
typedef QRect (QObject::*ProtoRect)() const;
typedef const QRect* (QObject::*PProtoRect)() const;
typedef const QRect& (QObject::*RProtoRect)() const;
typedef QSize (QObject::*ProtoSize)() const;
typedef const QSize* (QObject::*PProtoSize)() const;
typedef const QSize& (QObject::*RProtoSize)() const;
typedef QColor (QObject::*ProtoColor)() const;
typedef const QColor* (QObject::*PProtoColor)() const;
typedef const QColor& (QObject::*RProtoColor)() const;
typedef QPalette (QObject::*ProtoPalette)() const;
typedef const QPalette* (QObject::*PProtoPalette)() const;
typedef const QPalette& (QObject::*RProtoPalette)() const;
typedef QColorGroup (QObject::*ProtoColorGroup)() const;
typedef const QColorGroup* (QObject::*PProtoColorGroup)() const;
typedef const QColorGroup& (QObject::*RProtoColorGroup)() const;
typedef QIconSet (QObject::*ProtoIconSet)() const;
typedef const QIconSet* (QObject::*PProtoIconSet)() const;
typedef const QIconSet& (QObject::*RProtoIconSet)() const;
typedef QPoint (QObject::*ProtoPoint)() const;
typedef const QPoint* (QObject::*PProtoPoint)() const;
typedef const QPoint& (QObject::*RProtoPoint)() const;
typedef QBitmap (QObject::*ProtoBitmap)() const;
typedef const QBitmap* (QObject::*PProtoBitmap)() const;
typedef const QBitmap& (QObject::*RProtoBitmap)() const;
typedef QRegion (QObject::*ProtoRegion)() const;
typedef const QRegion* (QObject::*PProtoRegion)() const;
typedef const QRegion& (QObject::*RProtoRegion)() const;
typedef QPointArray (QObject::*ProtoPointArray)() const;
typedef const QPointArray* (QObject::*PProtoPointArray)() const;
typedef const QPointArray& (QObject::*RProtoPointArray)() const;
typedef QCursor (QObject::*ProtoCursor)() const;
typedef const QCursor* (QObject::*PProtoCursor)() const;
typedef const QCursor& (QObject::*RProtoCursor)() const;
typedef QImage (QObject::*ProtoImage)() const;
typedef const QImage* (QObject::*PProtoImage)() const;
typedef const QImage& (QObject::*RProtoImage)() const;
typedef QStringList (QObject::*ProtoStringList)() const;
typedef const QStringList* (QObject::*PProtoStringList)() const;
typedef const QStringList& (QObject::*RProtoStringList)() const;
typedef QValueList<QVariant> (QObject::*ProtoList)() const;
typedef const QValueList<QVariant>* (QObject::*PProtoList)() const;
typedef const QValueList<QVariant>& (QObject::*RProtoList)() const;
typedef QMap<QString,QVariant> (QObject::*ProtoMap)() const;
typedef const QMap<QString,QVariant>* (QObject::*PProtoMap)() const;
typedef const QMap<QString,QVariant>& (QObject::*RProtoMap)() const;
QMetaObject* meta = queryMetaObject();
if ( !meta )
return value;
const QMetaProperty* p = meta->property( name, TRUE );
if ( !p )
return value;
if ( p->isEnumType() ) {
ProtoInt m = (ProtoInt)p->get;
int x = (int) (this->*m)();
value = QVariant( x );
return value;
}
// p->type must be a type understood by QVariant, so we can savely convert it.
QVariant::Type type = QVariant::nameToType( p->type() );
switch ( type ) {
case QVariant::Invalid:
// A real assert, since this indicates a moc bug
ASSERT( 0 );
return QVariant();
case QVariant::Image:
if ( p->gspec == QMetaProperty::Class ) {
ProtoImage m = (ProtoImage)p->get;
value = QVariant( (this->*m)() );
} else if ( p->gspec == QMetaProperty::Reference ) {
RProtoImage m = (RProtoImage)p->get;
value = QVariant( (this->*m)() );
} else if ( p->gspec == QMetaProperty::Pointer ) {
PProtoImage m = (PProtoImage)p->get;
const QImage* p = (this->*m)();
if ( p )
value = QVariant( *p );
else
value = QVariant( QImage() );
} else {
ASSERT( 0 );
}
return value;
case QVariant::Point:
if ( p->gspec == QMetaProperty::Class ) {
ProtoPoint m = (ProtoPoint)p->get;
value = QVariant( (this->*m)() );
} else if ( p->gspec == QMetaProperty::Reference ) {
RProtoPoint m = (RProtoPoint)p->get;
value = QVariant( (this->*m)() );
} else if ( p->gspec == QMetaProperty::Pointer ) {
PProtoPoint m = (PProtoPoint)p->get;
const QPoint* p = (this->*m)();
if ( p )
value = QVariant( *p );
else
value = QVariant( QPoint() );
} else {
ASSERT( 0 );
}
return value;
case QVariant::StringList:
if ( p->gspec == QMetaProperty::Class ) {
ProtoStringList m = (ProtoStringList)p->get;
value = QVariant( (this->*m)() );
} else if ( p->gspec == QMetaProperty::Reference ) {
RProtoStringList m = (RProtoStringList)p->get;
value = QVariant( (this->*m)() );
} else if ( p->gspec == QMetaProperty::Pointer ) {
PProtoStringList m = (PProtoStringList)p->get;
const QStringList* p = (this->*m)();
if ( p )
value = QVariant( *p );
else
value = QVariant( QStringList() );
} else {
ASSERT( 0 );
}
return value;
case QVariant::List:
if ( p->gspec == QMetaProperty::Class ) {
ProtoList m = (ProtoList)p->get;
value = QVariant( (this->*m)() );
} else if ( p->gspec == QMetaProperty::Reference ) {
RProtoList m = (RProtoList)p->get;
value = QVariant( (this->*m)() );
} else if ( p->gspec == QMetaProperty::Pointer ) {
PProtoList m = (PProtoList)p->get;
const QValueList<QVariant>* p = (this->*m)();
if ( p )
value = QVariant( *p );
else
value = QVariant( QValueList<QVariant>() );
} else {
ASSERT( 0 );
}
return value;
case QVariant::CString:
if ( p->gspec == QMetaProperty::Class ) {
ProtoCString m = (ProtoCString)p->get;
value = QVariant( (this->*m)() );
} else if ( p->gspec == QMetaProperty::Reference ) {
RProtoCString m = (RProtoCString)p->get;
value = QVariant( (this->*m)() );
} else if ( p->gspec == QMetaProperty::Pointer ) {
PProtoCString m = (PProtoCString)p->get;
const QCString* p = (this->*m)();
if ( p )
value = QVariant( *p );
else
value = QVariant( QCString() );
} else if ( p->gspec == QMetaProperty::ConstCharStar ) {
ProtoConstCharStar m = (ProtoConstCharStar)p->get;
value = QVariant( QCString( (this->*m)() ) );
} else {
ASSERT( 0 );
}
return value;
case QVariant::String:
if ( p->gspec == QMetaProperty::Class ) {
ProtoString m = (ProtoString)p->get;
value = QVariant( (this->*m)() );
} else if ( p->gspec == QMetaProperty::Reference ) {
RProtoString m = (RProtoString)p->get;
value = QVariant( (this->*m)() );
} else if ( p->gspec == QMetaProperty::Pointer ) {
PProtoString m = (PProtoString)p->get;
const QString* p = (this->*m)();
if ( p )
value = QVariant( *p );
else
value = QVariant( QString() );
} else if ( p->gspec == QMetaProperty::ConstCharStar ) {
ProtoConstCharStar m = (ProtoConstCharStar)p->get;
value = QVariant( QCString( (this->*m)() ) );
} else {
ASSERT( 0 );
}
return value;
case QVariant::Font:
if ( p->gspec == QMetaProperty::Class ) {
ProtoFont m = (ProtoFont)p->get;
value = QVariant( (this->*m)() );
} else if ( p->gspec == QMetaProperty::Reference ) {
RProtoFont m = (RProtoFont)p->get;
value = QVariant( (this->*m)() );
} else if ( p->gspec == QMetaProperty::Pointer ) {
PProtoFont m = (PProtoFont)p->get;
const QFont* p = (this->*m)();
if ( p )
value = QVariant( *p );
else
value = QVariant( QFont() );
} else {
ASSERT( 0 );
}
return value;
case QVariant::Pixmap:
if ( p->gspec == QMetaProperty::Class ) {
ProtoPixmap m = (ProtoPixmap)p->get;
value = QVariant( (this->*m)() );
} else if ( p->gspec == QMetaProperty::Reference ) {
RProtoPixmap m = (RProtoPixmap)p->get;
value = QVariant( (this->*m)() );
} else if ( p->gspec == QMetaProperty::Pointer ) {
PProtoPixmap m = (PProtoPixmap)p->get;
const QPixmap* p = (this->*m)();
if ( p )
value = QVariant( *p );
else
value = QVariant( QPixmap() );
} else {
ASSERT( 0 );
}
return value;
case QVariant::Brush:
if ( p->gspec == QMetaProperty::Class ) {
ProtoBrush m = (ProtoBrush)p->get;
value = QVariant( (this->*m)() );
} else if ( p->gspec == QMetaProperty::Reference ) {
RProtoBrush m = (RProtoBrush)p->get;
value = QVariant( (this->*m)() );
} else if ( p->gspec == QMetaProperty::Pointer ) {
PProtoBrush m = (PProtoBrush)p->get;
const QBrush* p = (this->*m)();
if ( p )
value = QVariant( *p );
else
value = QVariant( QBrush() );
} else {
ASSERT( 0 );
}
return value;
case QVariant::Rect:
if ( p->gspec == QMetaProperty::Class ) {
ProtoRect m = (ProtoRect)p->get;
value = QVariant( (this->*m)() );
} else if ( p->gspec == QMetaProperty::Reference ) {
RProtoRect m = (RProtoRect)p->get;
value = QVariant( (this->*m)() );
} else if ( p->gspec == QMetaProperty::Pointer ) {
PProtoRect m = (PProtoRect)p->get;
const QRect* p = (this->*m)();
if ( p )
value = QVariant( *p );
else
value = QVariant( QRect() );
} else {
ASSERT( 0 );
}
return value;
case QVariant::Size:
if ( p->gspec == QMetaProperty::Class ) {
ProtoSize m = (ProtoSize)p->get;
value = QVariant( (this->*m)() );
} else if ( p->gspec == QMetaProperty::Reference ) {
RProtoSize m = (RProtoSize)p->get;
value = QVariant( (this->*m)() );
} else if ( p->gspec == QMetaProperty::Pointer ) {
PProtoSize m = (PProtoSize)p->get;
const QSize* p = (this->*m)();
if ( p )
value = QVariant( *p );
else
value = QVariant( QSize() );
} else {
ASSERT( 0 );
}
return value;
case QVariant::Color:
if ( p->gspec == QMetaProperty::Class ) {
ProtoColor m = (ProtoColor)p->get;
value = QVariant( (this->*m)() );
} else if ( p->gspec == QMetaProperty::Reference ) {
RProtoColor m = (RProtoColor)p->get;
value = QVariant( (this->*m)() );
} else if ( p->gspec == QMetaProperty::Pointer ) {
PProtoColor m = (PProtoColor)p->get;
const QColor* p = (this->*m)();
if ( p )
value = QVariant( *p );
else
value = QVariant( QColor() );
} else {
ASSERT( 0 );
}
return value;
case QVariant::Palette:
if ( p->gspec == QMetaProperty::Class ) {
ProtoPalette m = (ProtoPalette)p->get;
value = QVariant( (this->*m)() );
} else if ( p->gspec == QMetaProperty::Reference ) {
RProtoPalette m = (RProtoPalette)p->get;
value = QVariant( (this->*m)() );
} else if ( p->gspec == QMetaProperty::Pointer ) {
PProtoPalette m = (PProtoPalette)p->get;
const QPalette* p = (this->*m)();
if ( p )
value = QVariant( *p );
else
value = QVariant( QPalette() );
} else {
ASSERT( 0 );
}
return value;
case QVariant::ColorGroup:
if ( p->gspec == QMetaProperty::Class ) {
ProtoColorGroup m = (ProtoColorGroup)p->get;
value = QVariant( (this->*m)() );
} else if ( p->gspec == QMetaProperty::Reference ) {
RProtoColorGroup m = (RProtoColorGroup)p->get;
value = QVariant( (this->*m)() );
} else if ( p->gspec == QMetaProperty::Pointer ) {
PProtoColorGroup m = (PProtoColorGroup)p->get;
const QColorGroup* p = (this->*m)();
if ( p )
value = QVariant( *p );
else
value = QVariant( QColorGroup() );
} else {
ASSERT( 0 );
}
return value;
case QVariant::Bitmap:
if ( p->gspec == QMetaProperty::Class ) {
ProtoBitmap m = (ProtoBitmap)p->get;
value = QVariant( (this->*m)() );
} else if ( p->gspec == QMetaProperty::Reference ) {
RProtoBitmap m = (RProtoBitmap)p->get;
value = QVariant( (this->*m)() );
} else if ( p->gspec == QMetaProperty::Pointer ) {
PProtoBitmap m = (PProtoBitmap)p->get;
const QBitmap* p = (this->*m)();
if ( p )
value = QVariant( *p );
else
value = QVariant( QBitmap() );
} else {
ASSERT( 0 );
}
return value;
case QVariant::PointArray:
if ( p->gspec == QMetaProperty::Class ) {
ProtoPointArray m;
m = (ProtoPointArray)p->get;
value = QVariant( (this->*m)() );
} else if ( p->gspec == QMetaProperty::Reference ) {
RProtoPointArray m = (RProtoPointArray)p->get;
value = QVariant( (this->*m)() );
} else if ( p->gspec == QMetaProperty::Pointer ) {
PProtoPointArray m = (PProtoPointArray)p->get;
const QPointArray* p = (this->*m)();
if ( p )
value = QVariant( *p );
else
value = QVariant( QPointArray() );
} else {
ASSERT( 0 );
}
return value;
case QVariant::Region:
if ( p->gspec == QMetaProperty::Class ) {
ProtoRegion m = (ProtoRegion)p->get;
value = QVariant( (this->*m)() );
} else if ( p->gspec == QMetaProperty::Reference ) {
RProtoRegion m = (RProtoRegion)p->get;
value = QVariant( (this->*m)() );
} else if ( p->gspec == QMetaProperty::Pointer ) {
PProtoRegion m = (PProtoRegion)p->get;
const QRegion* p = (this->*m)();
if ( p )
value = QVariant( *p );
else
value = QVariant( QRegion() );
} else {
ASSERT( 0 );
}
return value;
case QVariant::Cursor:
if ( p->gspec == QMetaProperty::Class ) {
ProtoCursor m = (ProtoCursor)p->get;
value = QVariant( (this->*m)() );
} else if ( p->gspec == QMetaProperty::Reference ) {
RProtoCursor m = (RProtoCursor)p->get;
value = QVariant( (this->*m)() );
} else if ( p->gspec == QMetaProperty::Pointer ) {
PProtoCursor m = (PProtoCursor)p->get;
const QCursor* p = (this->*m)();
if ( p )
value = QVariant( *p );
else
value = QVariant( QCursor() );
} else {
ASSERT( 0 );
}
return value;
case QVariant::IconSet:
if ( p->gspec == QMetaProperty::Class ) {
ProtoIconSet m = (ProtoIconSet)p->get;
value = QVariant( (this->*m)() );
} else if ( p->gspec == QMetaProperty::Reference ) {
RProtoIconSet m = (RProtoIconSet)p->get;
value = QVariant( (this->*m)() );
} else if ( p->gspec == QMetaProperty::Pointer ) {
PProtoIconSet m = (PProtoIconSet)p->get;
const QIconSet* p = (this->*m)();
if ( p )
value = QVariant( *p );
else
value = QVariant( QIconSet() );
} else {
ASSERT( 0 );
}
return value;
case QVariant::Int:
if ( p->gspec == QMetaProperty::Class ) {
ProtoInt m = (ProtoInt)p->get;
value = QVariant( (this->*m)() );
} else if ( p->gspec == QMetaProperty::Reference ) {
RProtoInt m = (RProtoInt)p->get;
value = QVariant( (this->*m)() );
} else if ( p->gspec == QMetaProperty::Pointer ) {
PProtoInt m = (PProtoInt)p->get;
const int *p = (this->*m)();
if ( p )
value = QVariant( *p );
else
value = QVariant( 0 );
} else {
ASSERT( 0 );
}
return value;
case QVariant::UInt:
if ( p->gspec == QMetaProperty::Class ) {
ProtoUInt m = (ProtoUInt)p->get;
value = QVariant( (this->*m)() );
} else if ( p->gspec == QMetaProperty::Reference ) {
RProtoUInt m = (RProtoUInt)p->get;
value = QVariant( (this->*m)() );
} else if ( p->gspec == QMetaProperty::Pointer ) {
PProtoUInt m = (PProtoUInt)p->get;
const uint *p = (this->*m)();
if ( p )
value = QVariant( *p );
else
value = QVariant( 0 );
} else {
ASSERT( 0 );
}
return value;
case QVariant::Double:
if ( p->gspec == QMetaProperty::Class ) {
ProtoDouble m = (ProtoDouble)p->get;
value = QVariant( (this->*m)() );
} else if ( p->gspec == QMetaProperty::Reference ) {
RProtoDouble m = (RProtoDouble)p->get;
value = QVariant( (this->*m)() );
} else if ( p->gspec == QMetaProperty::Pointer ) {
PProtoDouble m = (PProtoDouble)p->get;
const double* p = (this->*m)();
if ( p )
value = QVariant( *p );
else
value = QVariant( 0.0 );
} else {
ASSERT( 0 );
}
return value;
case QVariant::Bool:
if ( p->gspec == QMetaProperty::Class ) {
ProtoBool m = (ProtoBool)p->get;
value = QVariant( (this->*m)(), 42 /* dummy */ );
} else if ( p->gspec == QMetaProperty::Reference ) {
RProtoBool m = (RProtoBool)p->get;
value = QVariant( (this->*m)(), 42 /* dummy */ );
} else if ( p->gspec == QMetaProperty::Pointer ) {
PProtoBool m = (PProtoBool)p->get;
const bool* p = (this->*m)();
value = QVariant( p ? *p : FALSE, 42 /* dummy */ );
} else {
ASSERT( 0 );
}
return value;
case QVariant::Map:
if ( p->gspec == QMetaProperty::Class ) {
ProtoMap m = (ProtoMap)p->get;
value = QVariant( (this->*m)() );
} else if ( p->gspec == QMetaProperty::Reference ) {
RProtoMap m = (RProtoMap)p->get;
value = QVariant( (this->*m)() );
} else if ( p->gspec == QMetaProperty::Pointer ) {
PProtoMap m = (PProtoMap)p->get;
const QMap<QString,QVariant>* p = (this->*m)();
if ( p )
value = QVariant( *p );
else
value = QVariant( QMap<QString,QVariant>() );
} else {
ASSERT( 0 );
}
return value;
}
return value;
}
qt'QObject::sender() (./qt-2.1.0/src/kernel/qobject.h:201)
inline const QObject *QObject::sender()
{
return sigSender;
}