port to qt5, extracted the writing part to a separate class