Unsolved Transferring project from qt to visual studio
-
I am having issues dealing with transferring my qt project to visual studio. My team is working on producing code in visual studio and i am trying to be able to bring my qt work in visual studio. I downloaded all the plugins for qt but im still getting a Lnk2019 unresolved external symbol error. I got it worked down to figure out its when qcustomplot is trying to be added to the visual studio project. I added the files in the folder and even linked the qtcustomplot folder. Is there something im doing wrong? I don't even have much code and it is still giving me this error. I have the qcustomplot.cpp and qcustomplot.h added to the project as well. Code and error below:
visualizer.h
#ifndef VISUALIZER_H #define VISUALIZER_H #include <QtWidgets/QMainWindow> #include "ui_visualizer.h" #include "qcustomplot.h" namespace Ui { class Visualizer; } class Visualizer : public QMainWindow { Q_OBJECT public: Visualizer(QWidget *parent = 0); ~Visualizer(); private: Ui::VisualizerClass ui; }; #endif // VISUALIZER_H main.cpp #include "visualizer.h" #include <QtWidgets/QApplication> int main(int argc, char *argv[]) { QApplication a(argc, argv); Visualizer w; w.show(); return a.exec(); }
visualizer.cpp
#include "visualizer.h" Visualizer::Visualizer(QWidget *parent) : QMainWindow(parent) { ui.setupUi(this); } Visualizer::~Visualizer() { }
error:
Severity Code Description Project File Line Suppression State
Error LNK2019 unresolved external symbol "__declspec(dllimport) public: __cdecl QPrinter::QPrinter(enum QPrinter::PrinterMode)" (_imp??0QPrinter@@QEAA@W4PrinterMode@0@@Z) referenced in function "public: bool __cdecl QCustomPlot::savePdf(class QString const &,int,int,enum QCP::ExportPen,class QString const &,class QString const &)" (?savePdf@QCustomPlot@@QEAA_NAEBVQString@@HHW4ExportPen@QCP@@00@Z) Visualizer c:\Users\kmile\OneDrive\documents\visual studio 2015\Projects\Visualizer\Visualizer\qcustomplot.obj 1^doesn't point to anything and several repeated types of this
-
@misoran
Hi
Do you also have
QT += printsupport
in the .pro file? -
I do. I have been playing with the code since i posted this. I was able to get rid of the error by taking out the qtcustomplot from the project and just linking the whole folder. However i think now because it is not linked to the project i am having issues connecting them. For example here is the part im talking about.
void Visualizer::setupDemo(int demoIndex) { switch (demoIndex) { case 0: setupForwardVelocityLocal(ui.customPlot); break; } setWindowTitle("Visualizer"); statusBar()->clearMessage(); ui.customPlot->replot(); }
if i do it this way it says "Ui::VisualizerClass" has no member "customplot "
ill give you my visualizer.h file here:
#ifndef VISUALIZER_H #define VISUALIZER_H #include <QtWidgets/QMainWindow> #include "ui_visualizer.h" #include "qcustomplot.h" namespace Ui { class Visualizer; } class Visualizer : public QMainWindow { Q_OBJECT public: Visualizer(QWidget *parent = 0); ~Visualizer(); void setupDemo(int demoIndex); void setupForwardVelocityLocal(QCustomPlot *customPlot); private: Ui::VisualizerClass ui; //Qstring demoName; QTimer dataTimer; QCPItemTracer *itemDemoPhaseTracer; int currentDemoIndex; };
is there somethign i need to add in order for the visual studio version to pick this up. This code also works completely fine in qtcreator as long as visualizer is mainwindow.
-
ok i was able to figure it out. If anyone find this the issue is that the ui which pop ups in the qt designer has to have that specific name. Such as i had to have a plot that says customplot or it would give me an error. Also when switching over it is best to take out qcustomplot.h and qcustomplot.cpp and just link the whole folder