See QScriptable class and the Qt Script presentation from DevDays2007 (search for "Qt Script Prototype Objects").