Hi guys,
I have a custom scene, implemented virtual methods:
void drawBackground..
void drawForeground..
void mouseMoveEvent ..
void mousePressEvent..
void keyPressEvent ..
void keyReleaseEvent..
void contextMenuEvent..
void drawBackground..
void drawForeground..
void mouseMoveEvent ..
void mousePressEvent..
void keyPressEvent ..
void keyReleaseEvent..
void contextMenuEvent..
To copy to clipboard, switch view to plain text mode
Here my view/scene settings
...
m_view
->setOptimizationFlag
(QGraphicsView::DontSavePainterState);
m_view
->setViewportUpdateMode
(QGraphicsView::FullViewportUpdate);
m_view
->setRenderHints
( QPainter::HighQualityAntialiasing);
m_view->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
m_view->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
m_view->setScene(m_scene);
m_view->setBackgroundColor(m_colorMap.value("NODTA"));
m_view->show();
m_scene->setItemIndexMethod(QGraphicsScene::NoIndex);
m_scene->setSceneRect(QRectF(QPointF(-180,-90),QPointF(180,90)));
...
m_view->setCacheMode(QGraphicsView::CacheBackground);
m_view->setOptimizationFlag(QGraphicsView::DontClipPainter);
m_view->setOptimizationFlag(QGraphicsView::DontSavePainterState);
m_view->setViewportUpdateMode(QGraphicsView::FullViewportUpdate);
m_view->setRenderHints( QPainter::HighQualityAntialiasing);
m_view->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
m_view->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
m_view->setScene(m_scene);
m_view->setSceneRect(QRectF(QPointF(-180,-90),QPointF(180,90)));
m_view->setBackgroundColor(m_colorMap.value("NODTA"));
m_view->show();
To copy to clipboard, switch view to plain text mode
This is the item I create in the scene/view owner class:
item
->setPen
(QPen(Qt
::red));
item
->setBrush
(QBrush(Qt
::red));
item->setVisible(true);
m_scene->addItem(item);
QGraphicsEllipseItem* item = new QGraphicsEllipseItem(QRectF(0,0,20,20));
item->setPen(QPen(Qt::red));
item->setBrush(QBrush(Qt::red));
item->setFlag(QGraphicsItem::ItemIsMovable);
item->setVisible(true);
m_scene->addItem(item);
To copy to clipboard, switch view to plain text mode
The ellipse is shown, can be selected(if I turn the flag on), but I can't move the item? The question is why?
Thanks.
Kacper
Bookmarks