@Painting

Почему появились эти ошибки?

Я делаю простое приложение в qt, в нем используется графическая сцена и кнопка. По нажатию кнопки в графической сцене должен появиться прямоугольник.
Но почему-то при запуске происходят ошибки:

C:\Users\123\Documents\paint3\main.cpp:-1: ошибка: undefined reference to `vtable for Paint'
:-1: ошибка: collect2.exe: error: ld returned 1 exit status
:-1: ошибка: [Makefile.Debug:71: debug/paint3.exe] Error

Сами файлы программы:

#pragma once
#include <QWidget>
#include <QGraphicsScene>
#include <QGraphicsView>
#include <QRectF>
#include <QPushButton>
#include <QGraphicsItem>
class Paint : public QWidget
{
Q_OBJECT
public:
Paint(QWidget *parent = 0);
QGraphicsScene *scene;
QGraphicsView *view;
QPushButton *btn;
private slots:
void Draw();
};


#include "paint.h"
#include <QtWidgets>
#include <QPushButton>
#include <QGraphicsItem>
Paint::Paint(QWidget *parent):QWidget(parent)
{
scene = new QGraphicsScene(QRectF(10,10,1000,1000));
view = new QGraphicsView(scene, this);
view->show();
btn = new QPushButton("Draw!", this);
btn -> setGeometry(1020, 10, 70, 30);
connect(btn, SIGNAL(clicked()), this, SLOT(Draw()));
}
void Paint::Draw()
{
QGraphicsRectItem *pRectItem = scene->addRect(QRectF(30,30, 120, 80), QPen(Qt::yellow), QBrush(Qt::green));
pRectItem ->setFlags(QGraphicsItem::ItemIsMovable);
}


Простите за возможно глупые ошибки.
Заранее спасибо...
  • Вопрос задан
  • 63 просмотра
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы