从Qt的低版本向5.1版本迁移的时候,发现QApplication: No such file or directory的问题。
解决方式如下:
In Qt5 QApplication is no longer part of QtGui module, it's now in QtWidgets.
In your #include
directive use <QtWidgets/QApplication>
, the same applies to QDialog.
如果同时出现以下错误:-1: error: note: '_ZN12QApplicationD1Ev' is defined in DSO /usr/lib/libQtGui.so.4 so try adding it to the linker command line
需要在pro文件中配置 LIBS += `pkg-config --libs QtGui QtCore`
如果要pkg-config能够查到正确的lib版本需要正确的配置
export PKG_CONFIG_PATH=$QTDIR/gcc/lib/pkgconfig:$PKG_CONFIG_PATH