The error you get is related to instantiating objects and not to defining classes. Most likely you have a static global variable of type derived or containing QWidget or you create a regular object before creating QApplication object, as the error message suggests.