Support building with Qt5

Extend Qt5 plus port some parts of the test suite.