Make double click work to put new items on the canvas.
Make double click work to put new items on the canvas. Those items right now are QGraphicsEllipseItems, but it will change to 'draggable' items. Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
This commit is contained in:
parent
beadeffaf5
commit
0d45c77572
@ -1,4 +1,5 @@
|
||||
#include "diveplanner.h"
|
||||
#include <QMouseEvent>
|
||||
|
||||
DivePlanner* DivePlanner::instance()
|
||||
{
|
||||
@ -8,4 +9,14 @@ DivePlanner* DivePlanner::instance()
|
||||
|
||||
DivePlanner::DivePlanner(QWidget* parent): QGraphicsView(parent)
|
||||
{
|
||||
setScene( new QGraphicsScene());
|
||||
scene()->setSceneRect(0,0,100,100);
|
||||
}
|
||||
|
||||
void DivePlanner::mouseDoubleClickEvent(QMouseEvent* event)
|
||||
{
|
||||
QGraphicsEllipseItem *item = new QGraphicsEllipseItem(-10,-10,20,20);
|
||||
item->setPos( mapToScene(event->pos()));
|
||||
scene()->addItem(item);
|
||||
}
|
||||
|
||||
|
||||
@ -8,6 +8,9 @@ class DivePlanner : public QGraphicsView {
|
||||
Q_OBJECT
|
||||
public:
|
||||
static DivePlanner *instance();
|
||||
protected:
|
||||
virtual void mouseDoubleClickEvent(QMouseEvent* event);
|
||||
|
||||
private:
|
||||
DivePlanner(QWidget* parent = 0);
|
||||
};
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user