最近在学QT,发现QT4中的一些示例程序在QT5中会报错。具体是关于打印机的一个函数会报:
undefined reference to `_imp___ZN8QPrinterC1ENS_11PrinterModeE
undefined reference to `_imp___ZN12QPrintDialogC1EP8QPrinterP7QWidget
undefined reference to `_imp___ZN20QAbstractPrintDialog16addEnabledOptionENS_17PrintDialogOptionE
undefined reference to `_imp___ZN12QPrintDialog4execEv
undefined reference to `_imp___ZN12QPrintDialogD1Ev
undefined reference to `_imp___ZN8QPrinterD1Ev
undefined reference to `_imp___ZN12QPrintDialogD1Ev
undefined reference to `_imp___ZN8QPrinterD1Ev
出现原因:
Qt 5中将所有打印的相关类都放到了Qt Print Support模块
解决方案:
在.pro文件中添加代码:qtHaveModule(printsupport): QT += printsupport