--- (Import): Generating new project of paint2.pro file--- (qmake) : Using: c:\qt\qt5.5.0\5.5\msvc2013_64\bin\qmake--- (qmake) : Working Directory: E:\Qt\APP2\paint2--- (qmake) : Arguments: -tp vc "paint2.pro" -o "paint2.vcxproj" QMAKE_INCDIR_QT=$(QTDIR)\include QMAKE_LIBDIR=$(QTDIR)\lib QMAKE_MOC=$(QTDIR)\bin\moc.exe QMAKE_QMAKE=$(QTDIR)\bin\qmake.exe[1] - Could not find qmake configuration file win32-msvc2013_64.[2] - Error processing project file: paint2.pro--- (Import): Error(s): 2--- (qmake) : Exit Code: 3--- (Import): Generating new project of paint2.pro file--- (qmake) : Using: c:\qt\qt5.5.0\5.5\msvc2013_64\bin\qmake--- (qmake) : Working Directory: E:\Qt\APP2\paint2--- (qmake) : Arguments: -tp vc "paint2.pro" -o "paint2.vcxproj" QMAKE_INCDIR_QT=$(QTDIR)\include QMAKE_LIBDIR=$(QTDIR)\lib QMAKE_MOC=$(QTDIR)\bin\moc.exe QMAKE_QMAKE=$(QTDIR)\bin\qmake.exe[1] - Could not find qmake configuration file win32-msvc2013_64.[2] - Error processing project file: paint2.pro--- (Import): Error(s): 2--- (qmake) : Exit Code: 3
[1] - Could not find qmake configuration file win32-msvc2013_64.
#include "paint.h"#include <QtWidgets>int main(int argc, char *argv[]){ QApplication a(argc, argv); paint w; w.show(); return a.exec();}
#ifndef PAINT_H#define PAINT_H#include <QtWidgets>class paint : public QWidget{ Q_OBJECTpublic: int btn; QVector<QPoint> vec; QVector<QPoint> vec2; explicit paint(QWidget *parent = 0);protected: virtual void paintEvent(QPaintEvent*); virtual void mousePressEvent(QMouseEvent * ev); virtual void mouseMoveEvent(QMouseEvent * ev2);signals:public slots:};#endif // PAINT_H
#include "paint.h"paint::paint(QWidget *parent) : QWidget(parent){}void paint::paintEvent(QPaintEvent *){ QPainter p(this); p.setPen(QPen(Qt::black,3)); if(btn==1){ p.setPen(QPen(Qt::white,3)); } for(int i = 0; i<vec.count(); ++i) { p.drawPoint(vec[i]); } for(int i = 1; i<vec2.count(); ++i) { p.drawLine(vec2[i-1],vec2[i]); } }void paint::mousePressEvent(QMouseEvent *ev){ if(ev->button()==Qt::RightButton){ btn=1; } else{ btn=0; } vec.insert(vec.end(),ev->pos()); this->repaint();}void paint::mouseMoveEvent(QMouseEvent *ev2){ vec2.insert(vec2.end(),ev2->pos()); this->repaint();}
C#vec.append(ev->pos());vec2 << ev2->pos()
C++ (Qt)for(int i = 1; i<vec2.count(); i += 2)