qq_22099861 2015-04-11 02:31 采纳率: 0%
浏览 3613

关于qt中lnk2019和lnklnk1120的错误。请看下我的代码哪里出现了问题

//Label.h-----------
#ifndef LABEL_H
#define LABEL_H

#include
#include
#include
#include
#include
#include
#include
#include
class MyItem:public QGraphicsItem
{
public:
MyItem(int m_x=0, int m_y=0, QString m_QSLabel="Label", int m_width=200, int m_height=50);
QRectF boundingRect()const;
void paint(QPainter * painter
, const QStyleOptionGraphicsItem * option
, QWidget * widget = 0);
private:
int m_x;
int m_y;
int m_width;
int m_height;
QString m_QSLabel;
};

#endif
//lable.cpp--------------
#include "label.h"

MyItem::MyItem(int x, int y, QString label, int width, int height ):m_x(x), m_y(y), m_QSLabel(label),m_width(width),m_height(height)
{

}
QRectF MyItem::boundingRect()const
{
return QRectF(0,0,100,100);
}
void MyItem::paint(QPainter painter,const QStyleOptionGraphicsItem *option,QWidget *widget)
{
/*painter->setPen(QPen(Qt::black,5,Qt::DashDotDotLine,Qt::RoundCap));
/
painter->setBrush(Qt::white);
painter->drawRect(m_x, m_y, m_width, m_height);
painter->drawLine(m_x, 50, m_x+80, 50);

QFont font("Arial",18);
painter->setFont(font);

QPoint *pPoint=new QPoint(m_x,m_y+32);
painter->setPen(QPen(Qt::red,30));
painter->drawText(*pPoint,m_QSLabel);

//----------------------------label完成------------------------------
QPoint start_pos(m_x+80,m_y+15);
QPoint end_pos(m_x+150,m_y+100);
QPainterPath path(start_pos);
QPoint c1((start_pos+end_pos).x()/2,start_pos.y());
QPoint c2((start_pos+end_pos).x()/2,end_pos.y());
path.cubicTo(c1,c2,end_pos);
painter->setPen(QPen(Qt::black,8));
painter->setBrush(QBrush(Qt::yellow,Qt::Dense7Pattern));
painter->drawPath(path);

}
//mainwindow.h
#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include "label.h"

namespace Ui {
class mainwindow;
}

class mainwindow : public QWidget
{
Q_OBJECT

public:
explicit mainwindow(QWidget *parent = 0);
~mainwindow();

private:
Ui::mainwindow *ui;
QGraphicsScene *scene;
QGraphicsView *view;
};

#endif // MAINWINDOW_H

//mainwindow.cpp

//#include "menubar.h"
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include
#include
#include "label.h"
//mianwindow中如何添加其他的控件??

mainwindow::mainwindow(QWidget *parent) : QWidget(parent)
,ui(new Ui::mainwindow)
{

setWindowFlags(Qt::FramelessWindowHint |Qt::WindowStaysOnTopHint);
scene = new QGraphicsScene;

//添加标签类

MyItem *itemA=new MyItem(150,0,"LabelA");
scene->addItem(itemA);

view = new QGraphicsView(scene);
view->setScene(scene);
view->resize(1024,768);
view->setWindowTitle("Godhand");
view->show();

}

mainwindow::~mainwindow()
{
delete ui;
}
//main.cpp
#include "mainwindow.h"
//#include "menubar.h"
#include
#include

int main(int argc, char *argv[])
{
QApplication a(argc, argv);
mainwindow mainWindow;

return a.exec();

}
帮忙我看下 如何解决这个lnk2019和lnk1120的错误求下讲解过程

  • 写回答

1条回答 默认 最新

  • threenewbee 2015-04-11 04:00
    关注

    link的错误一般是你重复定义函数,或者头文件没找到造成的

    评论

报告相同问题?

悬赏问题

  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器