modified for Qt, added serialization