CopperSpice Overview
MetaObject Macros

The following table details the "Q_" macros which have been maintained or modified for CopperSpice. These changes were made to expand functionality, provide more flexibility, and leverage new capabilities added in modern C++. The second column is a sample of how the macro or define might appear in your source code.

The PepperMill program was run once on the Qt source to convert the header files and modify some of the syntax. The modified header files were used to build CopperSpice. Neither moc nor QMake is required or used to compile and build the CopperSpice libraries.

You can use PepperMill to convert your application header files. We suggest reviewing the header files as you may want to optimize after running PepperMill. Alternatively, the header file changes can be done manually. This entire process is only done one time.


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)
[ new macro ] 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_FLAGS CS_FLAG(Food_Enum, Food_Flag)
Q_GADGET CS_GADGET(Ginger) Class name must be passed
Q_INTERFACES CS_INTERFACES() samples listed below
Q_INVOKABLE CS_INVOKABLE() samples listed below
Q_OBJECT CS_OBJECT(Ginger) Class name must be passed
[ new macro ] CS_OBJECT_MULTIPLE(Ginger, QObject) Class name is passed as the first parameter

Second parameter is the primary parent class in multiple inheritance
Q_OUTOFLINE_TEMPLATES Removed since compilers after C++11 understand templates
Q_PROPERTY CS_PROPERTY() samples listed below Each property is separated into individual macros

Template data types allowed, such as QMap<int, QString>
Q_RETURN_ARG   — Unchanged in CS
Q_SCRIPT_DECLARE_QMETAOBJECT   — Unchanged in CS
Q_SIGNAL CS_SIGNAL() samples listed below
Q_SIGNALS Remove, place signal macros in a public section All signals are registered individually
Q_SLOT CS_SLOT() samples listed below
Q_SLOTS Remove macro, no replacement required All slots are registered individually or declared as a method
[ new macro ] 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 = nullptr) )
   CS_INVOKABLE_CONSTRUCTOR_2(QObject, QObject *)

private:
   CS_INVOKABLE_CONSTRUCTOR_1(Private, MyClass(QObject * = nullptr) )
   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 = nullptr) )
   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)

Note
A slot only needs to be registered with the CS_SLOT macro when it is used from the connect() overload which contains the SLOT() macro. If you are using method pointers the slot does not need to be registered.