There is a bunch of examples on QtScript bundled with Qt.