Rewrite for Qt5