KTextTemplate::MetaType Class

class KTextTemplate::MetaType

The MetaType is the interface to the KTextTemplate introspection system. More...

Header: #include <KTextTemplate/MetaType>
CMake: find_package(KF6 REQUIRED COMPONENTS TextTemplate)
target_link_libraries(mytarget PRIVATE KF6::TextTemplate)

Macros

Detailed Description

The MetaType class is used as part of the type registration system of KTextTemplate.

Related Non-Members

template <typename RealType, typename HandleAs> int registerMetaType()

Registers the type RealType with the metatype system.

This method can take a second template parameter to specify a cast that should be invoked during registration. This is useful if a base type is already supported.

  class SomeType
  {
  public:
    QString someProp() const;
  };

  // define some introspectable API for SomeType

  KTEXTTEMPLATE_BEGIN_LOOKUP(SomeType)
    if (property == "someProp")
      return object.someProp();
  KTEXTTEMPLATE_END_LOOKUP


  class OtherType : public SomeType
  {
    // ...
  };

  registerMetaType<SomeType>();

  // Only the introspectable API from SomeType is needed, so we can reuse that
registration.
  registerMetaType<OtherType, SomeType>();

Macro Documentation

KTEXTTEMPLATE_BEGIN_LOOKUP(Type)

Top boundary of a lookup function for Type.

KTEXTTEMPLATE_BEGIN_LOOKUP_PTR(Type)

Top boundary of a lookup function for Type*.

KTEXTTEMPLATE_END_LOOKUP

Bottom boundary of a lookup function for Type.