|Home | Tutorial | Classes | Functions | QSA Workbench | Language | Qt API | QSA Articles | Qt Script for Applications |

# QSArgument Class Reference

The QSArgument class provides storage for various datatypes used in QSObjectFactory::create() calls. More...

`#include <qsargument.h>`

List of all member functions.

## Public Members

- enum Type { Invalid, Variant, QObjectPtr, VoidPointer }
- QSArgument ()
- QSArgument ( const QVariant & v )
- QSArgument ( QObject * o )
- QSArgument ( void * p )
- QVariant variant () const
- QObject * qobject () const
- void * ptr () const
- Type type () const
- QString typeName () const

## Detailed Description

The QSArgument class provides storage for various datatypes used in QSObjectFactory::create() calls.

When the user writes Qt Script code like this:

        var x = new AnotherCppObject( arg1, arg2 ); // Qt Script

the arguments are passed to the QSObjectFactory::create() call as a QValueList of QSArguments. A QSArgument can hold a QVariant, a QObject pointer or a void pointer. The type held by a QSArgument is returned by type() and the value is returned by variant(), qobject(), or ptr(), depending on the QSArgument type.

## Member Type Documentation

### QSArgument::Type

This enum describes which datatype is held by this QSArgument.

- `QSArgument::Invalid` - Invalid datatype
- `QSArgument::Variant` - Holds a QVariant
- `QSArgument::QObjectPtr` - Holds a QObject pointer
- `QSArgument::VoidPointer` - Holds an untyped pointer (void*)

## Member Function Documentation

### QSArgument::QSArgument ()

Creates an invalid QSArgument

### QSArgument::QSArgument ( const QVariant & v )

Creates a QSArgument which holds the variant v as its value and is of type Variant.

### QSArgument::QSArgument ( QObject * o )

Creates a QSArgument which holds the QObject pointer o as its value and is of type QObjectPtr.

### QSArgument::QSArgument ( void * p )

Creates a QSArgument which holds the pointer p as its value and is of type VoidPointer.

### void * QSArgument::ptr () const

If this QSArgument's type() is VoidPointer, it returns the void pointer; otherwise returns 0.

### QObject * QSArgument::qobject () const

If this QSArgument's type() is QObjectPtr, it returns the object pointer; otherwise returns 0.

### Type QSArgument::type () const

Returns the type of this QSArgument. This can be Invalid, Variant, QObjectPtr, or VoidPointer

See also typeName().

### QString QSArgument::typeName () const

Returns the type name of this argument.

### QVariant QSArgument::variant () const

If this QSArgument's type() is Variant, it returns the variant value; otherwise returns an invalid variant.

This file is part of Qt Script for Applications, copyright © 2001-2004 Trolltech. All Rights Reserved.