My own widget: undefined reference to imp_...
-
Hi,
I'm trying to use a widget from my superior (a graph). When I try to include it and so on, and compile it, these errors appear (there are so much, so I've just made a screenshot out of it):
!http://i.epvpimg.com/MLfUc.png(errors img)!
One example error:
@R:\source\Qt-Creator\LaserSimulation\LaserSimulation.cpp:10: Fehler:undefined reference to `_imp___ZN12QApplication4execEv'@Here are the codes..
LaserSimulation.pro
@SOURCES +=
LaserSimulation.cpp
abkgraph.cppHEADERS +=
LaserSimulation.h
abkgraph.h@abkgraph.h
@#ifndef ABKGRAPH_H
#define ABKGRAPH_H#include <QtWidgets/QWidget>
#include <QObject>class CAbkGraph : public QWidget
{
Q_OBJECT
public:
explicit CAbkGraph(QWidget *parent = 0);
void paintEvent(QPaintEvent *event);
void resizeEvent(QResizeEvent * event);
void setValues(int nCount, unsigned short * pValues);signals:
public slots:
private:
/* Layout settings */
float m_fGapLeft;
float m_fGapRight;
float m_fGapTop;
float m_fGapBottom;/* Scaling */ int m_nValues; float m_fYMax; /* Values */ unsigned short * m_pusValues; /* Pixmaps */ QPixmap * m_pPixmapGraph; /* Colors */ QColor m_colGraphBg;
private:
void createGraph();/* Helper methods */ int VAL2PIX(float value, float maxVal, int maxPix);
};
#endif // ABKGRAPH_H
@abkgraph.cpp
@
#include "abkgraph.h"#include <QPainter>
#include <QMouseEvent>
#include <QResizeEvent>CAbkGraph::CAbkGraph(QWidget *parent) :
QWidget(parent)
{
m_pPixmapGraph = NULL;
m_colGraphBg = QColor(255,255,255);m_fGapBottom = 0.1; m_fGapLeft = 0.1; m_fGapRight = 0.1; m_fGapTop = 0.1; m_pusValues = NULL; m_nValues = 1000; m_fYMax = 32000;
}
void CAbkGraph::paintEvent(QPaintEvent *event){
QPainter painter(this);
createGraph();
painter.drawPixmap(0,0,*m_pPixmapGraph);}
/*
Resize event is called whenever the widgets gets resized
/
void CAbkGraph::resizeEvent(QResizeEvent * event){
/ Create pixmaps in the needed size */
if(m_pPixmapGraph!=NULL) delete m_pPixmapGraph;m_pPixmapGraph = new QPixmap(size()); createGraph();
}
/*
Draws the Background of the widget
*/
void CAbkGraph::createGraph(){m_pPixmapGraph->fill(Qt::transparent); QPainter painter(m_pPixmapGraph); painter.setRenderHint(QPainter::Antialiasing,true); /* Draw the background of the whole widget */ painter.setPen(QPen(QBrush(QColor(255,255,255)),1)); painter.setBrush(QBrush(QColor(190,190,190))); painter.drawRect(0,0,size().width(),size().height()); /* Draw the graph area */ painter.setPen(QPen(QBrush(QColor(0,0,0)),1)); painter.setBrush(QBrush(m_colGraphBg)); int l = width() *m_fGapLeft; int t = height() * m_fGapTop; int r = width() - (width() * m_fGapRight); int b = height()- (height() * m_fGapBottom); painter.drawRect(l,t,r-l,b-t); /* Draw the graph */ painter.setPen(QPen(QBrush(QColor(255,0,0)),1)); QPainterPath path; painter.setBrush(QBrush(Qt::NoBrush)); if(m_pusValues==NULL) return; int h= b-t; path.moveTo(0,b-VAL2PIX(m_pusValues[0],m_fYMax,h)); /* peak of the arrow (left)*/ for(int p=1;p<m_nValues;p++){ int x = VAL2PIX(p,m_nValues,r-l); int y = b-VAL2PIX(m_pusValues[p],m_fYMax,h); path.lineTo(x,y); } path.translate(l,0); painter.drawPath(path);
}
int CAbkGraph::VAL2PIX(float value, float maxVal, int maxPix){
return (maxPix * value)/maxVal;
}void CAbkGraph::setValues(int nCount, unsigned short * pValues){
m_nValues = nCount;
m_pusValues = pValues;
repaint();
}
@LaserSimulation.h
@#ifndef LASERSIMULATION_H
#define LASERSIMULATION_H#endif // LASERSIMULATION_H
@LaserSimulation.cpp
@#include <QtWidgets/QApplication>
#include <../abkgraph/abkgraph.h>int main(int argc, char **argv)
{
QApplication app (argc, argv);
CAbkGraph abkGraph;
abkGraph.show();
return app.exec();
}
@Help please!
-
Embarrassing. Look at my PRO file. There's missing the QT = stuff:
@QT = core gui
QT = core gui widgets@Now it works!
-
QT = xxxx
will overwrite previous setting of QT
if you want to add a new module, please use QT += xxxxx
Please take a look on qmake doc, it is a pretty powerful makefile generate tool
you don't need to know everything of it(like me :) )
but know some basic of it could help you avoid some arcane errors -
just like what stereomatching said, you d better do some reading about the basic information, which will help you using Qt more effectively
http://qt-project.org/doc/qt-4.8/qmake-project-files.html