GraphicsTestApp
::GraphicsTestApp(QWidget *parent, Qt
::WFlags flags
){
ui.setupUi(this);
m_Scene->setSceneRect ( 0, 0, 500, 500 ) ;
m_RectItem1
= m_Scene
->addRect
(QRectF(100,
100,
50,
100));
m_RectItem2
= m_Scene
->addRect
(QRectF(10,
10,
10,
10));
m_RectItem2->setParentItem(m_RectItem1);
m_RectItem2->setPos(0,0);
qDebug() << m_RectItem1->scenePos();
qDebug() << m_RectItem1->pos();
qDebug() << m_RectItem1->boundingRect();
qDebug() << m_RectItem2->scenePos();
qDebug() << m_RectItem2->pos();
qDebug() << m_RectItem2->boundingRect();
ui.graphicsView->setScene(m_Scene);
}
GraphicsTestApp::GraphicsTestApp(QWidget *parent, Qt::WFlags flags)
: QMainWindow(parent, flags)
{
ui.setupUi(this);
m_Scene = new QGraphicsScene();
m_Scene->setSceneRect ( 0, 0, 500, 500 ) ;
m_RectItem1 = m_Scene->addRect(QRectF(100,100,50,100));
m_RectItem2 = m_Scene->addRect(QRectF(10,10,10,10));
m_RectItem2->setParentItem(m_RectItem1);
m_RectItem2->setPos(0,0);
qDebug() << m_RectItem1->scenePos();
qDebug() << m_RectItem1->pos();
qDebug() << m_RectItem1->boundingRect();
qDebug() << m_RectItem2->scenePos();
qDebug() << m_RectItem2->pos();
qDebug() << m_RectItem2->boundingRect();
ui.graphicsView->setScene(m_Scene);
}
To copy to clipboard, switch view to plain text mode
Bookmarks