[Casa-framework] variants

David King dking at nrao.edu
Fri Sep 15 11:23:14 EDT 2006


Kumar Golap wrote:
> 
> Any example you can point me to the usage of a variant....A variant
> i'm guessing is a variable with no fixed  type ...am i right ?

Yes.  Another example is Qt's fairly-handy version, QVariant.  It only needs 
the QtCore (non-gui) library (and no special compiling tricks at all).

There is a macro to register any type you want to be held in a QVariant, 
e.g. (from QtDisplayData.qo.h):

   Q_DECLARE_METATYPE(casa::MyClass)

That allows rather clean extraction syntax like (see QtDisplayPanelGui.cc):

   MyClass myObject = qVariant.value<MyClass>();

The setting syntax is even simpler:

   qVariant.setValue(myObject);



More information about the Casa-framework mailing list