官方文档上说明了,如果是自己qmake的话,得加上qt += widgets:
You could also use qmake's -project option to generate the .pro file. Although, in that case, you have to remember to add the line QT += widgets to the generated file in order to link against the Qt Widgets Module.