CopperSpice Overview  1.5.1
MetaObject Macros

The following table details the "Q_" macros which have been maintained or modified for CopperSpice. These changes were done to expand functionality, provide more flexibility, and leverage new capabilities added in C++11.

The PepperMill program was run on the Qt source to convert the header files. These new header files were used to build CopperSpice. Neither Moc nor QMake was used to compile and build the CopperSpice libraries.

The PepperMill conversion program can be used to convert your application header files. You may wish to review or optimize your header files after running PepperMill. Alternatively, the header file changes can be done manually. This process is only done one time.

The second column in the table shows a sample of how the macro or define might appear in your source code.

Define Sample Description
Q_ARG   — Unchanged in CS
Q_CLASSINFO CS_CLASSINFO("project", "PepperMill")
Q_DECLARE_EXTENSION_INTERFACE   — Unchanged in CS
Q_DECLARE_FLAGS   — Unchanged in CS
Q_DECLARE_INTERFACE CS_DECLARE_INTERFACE(ShapeInterface, "id")
Q_DECLARE_METATYPE   — Unchanged in CS
Q_DECLARE_OPERATORS_FOR_FLAGS   — Unchanged in CS
Q_DECLARE_TR_FUNCTIONS   — Unchanged in CS
Q_DECLARE_TYPEINFO   — Unchanged in CS
Q_DISABLE_COPY   — Unchanged in CS
Q_ENUMS CS_ENUM(Spices)
[ Did not exist in Qt ] CS_REGISTER_ENUM( enum Spices {mint, basil}; ) Enums must be registered when used as the value of a Property
Q_EMIT Not required Signal & Slot declarations must be in the appropriate "public", "protected", or "private" section of the header file
Q_EXPORT_PLUGIN2   — Unchanged in CS
Q_FLAGS CS_FLAG(Food_Enum, Food_Flag)
Q_GADGET CS_GADGET(Ginger) Class name must be passed as a parameter
Q_IMPORT_PLUGIN   — Unchanged in CS
Q_INTERFACES CS_INTERFACES() samples listed below
Q_INVOKABLE CS_INVOKABLE() samples listed below
Q_OBJECT CS_OBJECT(Ginger) Class name must be passed as a parameter
[ Did not exist in Qt ] CS_OBJECT_MULTIPLE(Ginger, QObject) Class name is passed as the first parameter

Second parameter is the primary parent class in multiple inheritance
Q_PROPERTY CS_PROPERTY() samples listed below Each property is separated into an individual macro

Template data types allowed. For example, QMap<int, QString> is valid
Q_RETURN_ARG   — Unchanged in CS
Q_SCRIPT_DECLARE_QMETAOBJECT   — Unchanged in CS
Q_SIGNAL CS_SIGNAL() samples listed below
Q_SIGNALS Replace macro with "public:" (Refer to Q_SIGNAL) Not supported, every Signal must be registered individually
Q_SLOT CS_SLOT() samples listed below
Q_SLOTS Remove macro Not supported, every Slot must be registered individually
[ Did not exist in Qt ] CS_TAG("myTag", myMethod() ) Associates a 'tag' with a method, refer to QMetaMethod::tag()


Samples for CS_INTERFACES

   CS_INTERFACES(QSqlDriverFactoryInterface, QFactoryInterface)
   CS_INTERFACES(QTextCodecFactoryInterface, QFactoryInterface)

Samples for CS_INVOKABLE

public:
   CS_INVOKABLE_CONSTRUCTOR_1(Public, explicit QObject(QObject *parent = 0) )
   CS_INVOKABLE_CONSTRUCTOR_2(QObject, QObject *)

private:
   CS_INVOKABLE_CONSTRUCTOR_1(Private, MyClass(QObject * = 0) )
   CS_INVOKABLE_CONSTRUCTOR_2(MyClass, QObject *)

public:
   CS_INVOKABLE_METHOD_1(Public, bool callable_Method(QString data) )
   CS_INVOKABLE_METHOD_2(callable_Method)

Samples for CS_PROPERTY

CS_PROPERTY_READ(title, getTitle)
CS_PROPERTY_WRITE(title, setTitle)
CS_PROPERTY_RESET(title, resetTitle)
CS_PROPERTY_NOTIFY(title, titleChanged)
CS_PROPERTY_REVISION(title, 31415)
CS_PROPERTY_DESIGNABLE(title, true)
CS_PROPERTY_DESIGNABLE_NONSTATIC(title, true)
CS_PROPERTY_SCRIPTABLE(title, false )
CS_PROPERTY_SCRIPTABLE_NONSTATIC(title, isScriptTitle() )
CS_PROPERTY_STORED(title, true)
CS_PROPERTY_STORED_NONSTATIC(title, m_title.isEmpty() )
CS_PROPERTY_USER(title, true )
CS_PROPERTY_USER_NONSTATIC(title, (m_title.size() > 5) )
CS_PROPERTY_CONSTANT(title)
CS_PROPERTY_FINAL(title)

Samples for CS_SIGNAL

public:
   CS_SIGNAL_1(Public, void clicked(bool checked = false) )
   CS_SIGNAL_2(clicked, checked)

protected:
   CS_SIGNAL_1(Protected, void mySignal( void(*someVar)(int, bool)) )
   CS_SIGNAL_2(mySignal, someVar)

private:
   CS_SIGNAL_1(Private, void mapMethod(QList<QMap<double, int>> data) )
   CS_SIGNAL_2(mapMethod, data)

public:
   CS_SIGNAL_1(Public, void released() )
   CS_SIGNAL_OVERLOAD(released, ())

   CS_SIGNAL_1(Public, void released(int leftbutton, int rightbutton) )
   CS_SIGNAL_OVERLOAD(released, (int, int), leftbutton, rightbutton)

Samples for CS_SLOT

public:
   CS_SLOT_1(Public, void closePB(QObject *SomeObject = 0) )
   CS_SLOT_2(closePB)

   CS_SLOT_1(Public, bool on_closePB_clicked() )
   CS_SLOT_2(on_closePB_clicked)

   CS_SLOT_1(Public, void on_released() )
   CS_SLOT_OVERLOAD(on_released,())

   CS_SLOT_1(Public, void on_released(bool isDone) )
   CS_SLOT_OVERLOAD(on_released,(bool))

protected:
   CS_SLOT_1(Protected, int mySlotName(int count) )
   CS_SLOT_2(mySlotName)

private:
   CS_SLOT_1(Private, void refresh(QString data) )
   CS_SLOT_2(refresh)