croExpander {
   public:
     MyExpander( MyClass *_that ) : KWordMacroExpander(), that( _that ) {}
   protected:
     virtual bool expandMacro( const QString &amp;str, QStringList &amp;ret );
   private:
     MyClass *that;
 };

 bool MyExpander.expandMacro( const QString &amp;str, QStringList &amp;ret )
 {
   if (str == "macro") {
     ret += complexOperation( that-&gt;m_str );
     return true;
   }
   return false;
 }

 ... MyClass....(...)
 {
   QString str;
   ...
   MyExpander mx( this );
   mx.expan