I'm using the simple example from tutorial to show an rectangle on a scene.
As I understand the axises are in the middle of the graphicalView, right?
What I don't understand is why changing x,y of rectangle doesn't do anything.
Here is the code
QtGuiApplication1
::QtGuiApplication1(QWidget *parent
){
ui.setupUi(this);
ui.graphicsView->setBackgroundBrush(Qt::red);
ui.graphicsView->setScene(_graphicsScene);
QPen blackPen
(Qt
::black);
blackPen.setWidth(6);
_graphicsScene->addRect(0, 0, 100, 100, blackPen, redBrush);
}
QtGuiApplication1::QtGuiApplication1(QWidget *parent)
: QMainWindow(parent)
{
ui.setupUi(this);
ui.graphicsView->setBackgroundBrush(Qt::red);
_graphicsScene = new QGraphicsScene(this);
ui.graphicsView->setScene(_graphicsScene);
QBrush redBrush(Qt::yellow);
QPen blackPen(Qt::black);
blackPen.setWidth(6);
_graphicsScene->addRect(0, 0, 100, 100, blackPen, redBrush);
}
To copy to clipboard, switch view to plain text mode
The result
Untitled.jpg
Even if I change x,y of the rect to
addRect(50, 50, 100, 100, blackPen, redBrush)
addRect(50, 50, 100, 100, blackPen, redBrush)
To copy to clipboard, switch view to plain text mode
or
addRect(10000, 10000, 100, 100, blackPen, redBrush)
addRect(10000, 10000, 100, 100, blackPen, redBrush)
To copy to clipboard, switch view to plain text mode
it shows the same position of the rectangle. Why?
Untitled.jpg
Bookmarks