Improve drawing experiance
This commit is contained in:
parent
99f9171951
commit
49d556569f
@ -9,15 +9,20 @@ LineItem::~LineItem()
|
|||||||
delete path;
|
delete path;
|
||||||
}
|
}
|
||||||
|
|
||||||
void LineItem::mouseDragEvent(QGraphicsSceneMouseEvent *e, CropScene *)
|
void LineItem::mouseDragEvent(QGraphicsSceneMouseEvent *e, CropScene *scene)
|
||||||
{
|
{
|
||||||
if (path == nullptr)
|
if (path == nullptr)
|
||||||
|
{
|
||||||
path = new QPainterPath(e->scenePos());
|
path = new QPainterPath(e->scenePos());
|
||||||
|
pathItem = scene->addPath(*path, scene->pen(), scene->brush());
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
path->lineTo(e->scenePos());
|
path->lineTo(e->scenePos());
|
||||||
|
pathItem->setPath(*path);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void LineItem::mouseDragEndEvent(QGraphicsSceneMouseEvent *, CropScene *scene)
|
void LineItem::mouseDragEndEvent(QGraphicsSceneMouseEvent *, CropScene *)
|
||||||
{
|
{
|
||||||
scene->addPath(*path, scene->pen(), scene->brush());
|
|
||||||
}
|
}
|
||||||
|
@ -18,6 +18,7 @@ class LineItem : public DrawItem
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
QPainterPath *path = nullptr;
|
QPainterPath *path = nullptr;
|
||||||
|
QGraphicsPathItem *pathItem = nullptr;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // LINEITEM_HPP
|
#endif // LINEITEM_HPP
|
||||||
|
6
main.cpp
6
main.cpp
@ -1,7 +1,7 @@
|
|||||||
#include "mainwindow.hpp"
|
#include "mainwindow.hpp"
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
#include <QCommandLineParser>
|
#include <QCommandLineParser>
|
||||||
#include <QDebug>
|
#include <QTimer>
|
||||||
#include <QtGlobal>
|
#include <QtGlobal>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
@ -51,6 +51,8 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
MainWindow w;
|
MainWindow w;
|
||||||
w.show();
|
w.show();
|
||||||
if (parser.isSet(h)) w.hide();
|
QTimer::singleShot(0, [&] {
|
||||||
|
if (parser.isSet(h)) w.hide();
|
||||||
|
});
|
||||||
return a.exec();
|
return a.exec();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user