diff --git a/cropeditor/drawing/lineitem.cpp b/cropeditor/drawing/lineitem.cpp index c253bb6..66d72f0 100644 --- a/cropeditor/drawing/lineitem.cpp +++ b/cropeditor/drawing/lineitem.cpp @@ -9,15 +9,20 @@ LineItem::~LineItem() delete path; } -void LineItem::mouseDragEvent(QGraphicsSceneMouseEvent *e, CropScene *) +void LineItem::mouseDragEvent(QGraphicsSceneMouseEvent *e, CropScene *scene) { if (path == nullptr) + { path = new QPainterPath(e->scenePos()); + pathItem = scene->addPath(*path, scene->pen(), scene->brush()); + } else + { 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()); } diff --git a/cropeditor/drawing/lineitem.hpp b/cropeditor/drawing/lineitem.hpp index 9899c6d..4c48a92 100644 --- a/cropeditor/drawing/lineitem.hpp +++ b/cropeditor/drawing/lineitem.hpp @@ -18,6 +18,7 @@ class LineItem : public DrawItem private: QPainterPath *path = nullptr; + QGraphicsPathItem *pathItem = nullptr; }; #endif // LINEITEM_HPP diff --git a/main.cpp b/main.cpp index f2e7db9..fe3eaa4 100644 --- a/main.cpp +++ b/main.cpp @@ -1,7 +1,7 @@ #include "mainwindow.hpp" #include #include -#include +#include #include #include @@ -51,6 +51,8 @@ int main(int argc, char *argv[]) MainWindow w; w.show(); - if (parser.isSet(h)) w.hide(); + QTimer::singleShot(0, [&] { + if (parser.isSet(h)) w.hide(); + }); return a.exec(); }