Qt 5.1 QApplication: No such file or directory

来源:互联网 发布:java 列出n之前的质数 编辑:程序博客网 时间:2024/05/01 06:18

从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 #includedirective 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--libsQtGuiQtCore`


如果要pkg-config能够查到正确的lib版本需要正确的配置

export PKG_CONFIG_PATH=$QTDIR/gcc/lib/pkgconfig:$PKG_CONFIG_PATH