c++ - Find the center position of a QGraphicsScene? -


I have tried to use the following code to add a line to my view:

  line = new QGraphicsLineItem (200,55,200,55); Mscene.addItem (ruler);  

But it seems that the coordination of QGraphicsLineItem starts at the left corner. I do not want to change the original in any way. I just want to regain the coordination of the position of the center of the QigraphicsScene / Qigraphixview. Which function do I use?

  line = new QGraphicsLineItem (200,55,200,55); Mscene.addItem (ruler);  

As a state for this creator of QGraphicsLineItem: -

creates a QGraphicsLineItem, (x1, y1) and ( X2, y2) as the default line.

This creates a QGraphicsLineItem with local coordinates (200, 55, 200, 55), so the line you are creating Is the beginning and closes the coordinates on the same point (200, 55).

Once you create a line object and add it to view, you can make a call to your position. To get the status of the visual center, you can use it and: -

  // Assume that PSCEN QGraphicsScene line-> SetOps (PSCAN-> width () / 2, PSCN -> height () / 2);  

QGraphicsView is just a window to see in a scene, so in this case, the item may be in the center of the view, but can not be seen in the middle .

You can place

on an item with a call in a visual center.

Comments

Popular posts from this blog

java - Can't add JTree to JPanel of a JInternalFrame -

javascript - data.match(var) not working it seems -

javascript - How can I pause a jQuery .each() loop, while waiting for user input? -