Modified to work with Qt 5.