When I try to declare QPrinter anywhere in my code I get the following errors:
Error 1 error LNK2019: unresolved external symbol "__declspec(dllimport)
public: virtual __thiscall QPrinter::~QPrinter(void)" (__imp_??1QPrinter@@UAE@XZ)
referenced in function "private: void __thiscall ezXpns::on_loginButton_clicked(void)" (?
on_loginButton_clicked@ezXpns@@AAEXXZ)
(path)\TestBuild_April3\TestBuild\ezxpns.obj TestBuild
Error 2 error LNK2019: unresolved external symbol "__declspec(dllimport)
public: __thiscall QPrinter::QPrinter(enum QPrinter::PrinterMode)" (__imp_??
0QPrinter@@QAE@W4PrinterMode@0@@Z) referenced in function "private: void __thiscall
ezXpns::on_loginButton_clicked(void)" (?on_loginButton_clicked@ezXpns@@AAEXXZ)
(path)\TestBuild_April3\TestBuild\ezxpns.obj TestBuild
After searching I found it implies, that linker can find method declaration, but not method itself. Also, it appears to fail at any mention of QPrinter
. I thought that might be because this method is depreciated in QT5, but it appears new method of QT-printer communication was not yet released. What could be the problem? #IFDEF
preprocessor declarations in QPrinter files?
My includes:
#include <QtWidgets/QMainWindow>
#include "ui_ezxpns.h"
#include "Vector2D.h"
#include <QtPrintSupport\qprinter.h>
#include <QtPrintSupport\qprintdialog.h>
#include <QtPrintSupport\qtprintsupportglobal.h>
#include <qapplication.h>
I assume you didn't enable QtPrintSupport for your project. You can enable it by adding
QT += printsupport
to your .pro file.
For more information, read here.