I am trying to work with centerOn, but can't make it work :s..
My code looks like this and the centerOn is not doing anything.
Creating scene:
self.scene.setSceneRect(0, 0, 700, 700)
self.scene = QtWidgets.QGraphicsScene()
self.scene.setSceneRect(0, 0, 700, 700)
self.view = QtWidgets.QGraphicsView(self.scene, self)
To copy to clipboard, switch view to plain text mode
Creating rect, that player can control:
self.
item.
setBrush(QtGui.
QBrush(QtGui.
QColor(color
[0], color
[1],color
[2]), QtCore.
Qt.
SolidPattern))self.scene.addItem(self.item)
self.newplayer = Player(color, self.starting, self.item, self.view)
self.item = QtWidgets.QGraphicsRectItem(-300, 500, 50, 50)
self.item.setBrush(QtGui.QBrush(QtGui.QColor(color[0], color[1],color[2]), QtCore.Qt.SolidPattern))
self.scene.addItem(self.item)
self.newplayer = Player(color, self.starting, self.item, self.view)
To copy to clipboard, switch view to plain text mode
And in Players class init function I am trying to call:
self.view.centerOn(self.item)
self.view.centerOn(self.item)
To copy to clipboard, switch view to plain text mode
Bookmarks