unexpected error in a simple class
-
In my code I get an error about declaration and definition of a class
Compilator says that error might be caused by tools Desktop Qt 5.10.1 MSVC2017 64bit however i reinstalled it and the eror still exists.
.h
class MyWidget : public QWidget
{
public: void paintEvent(QPaintEvent * );
};
.cpp
class MyWidget: public QWidget
{public:
void paintEvent(QPaintEvent * )
{
QPainter painter(this);
painter.setPen(Qt::black);
painter.drawRect(100,100,100,100);
}
}; -
unfortunately error still exists
error C2011 process ended with code 2
MIght be that the problem is bad configuration of Desktop Qt 5.10.1 MSVC2017 64bit
While doing "Make".It is my translation from Polish.h file
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
//#ifndef Q_OBJECT
//#define Q_OBJECT#include <QMainWindow>
namespace Ui {
class MainWindow;
}class MainWindow : public QMainWindow
{
Q_OBJECTpublic:
explicit MainWindow(QWidget *parent = 0);
~MainWindow();private:
Ui::MainWindow *ui;
};
class MyWidget : public QWidget
{
public: void paintEvent(QPaintEvent * );};
#endif // MAINWINDOW_H
//#endif //Q_OBJECT.cpp file
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include<QRect>
#include<QPainter>
#include<QWidget>
#include<QtGui>MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
MyWidget * mywidget = new MyWidget();
setCentralWidget(mywidget);
}MainWindow::~MainWindow()
{
delete ui;
}class MyWidget: public QWidget
{public:
void paintEvent(QPaintEvent * )
{
QPainter painter(this);
painter.setPen(Qt::black);
painter.drawRect(100,100,100,100);
}};
-