ported to qt, untested