QTableWidget
クリックするたびにマウスクリック座標を追加するにはどうすればよいですか?すでにQMouseEvent
座標を表示する必要QLabelItem
がありますが、クリックするたびに座標を含む行を追加したいと思います。これは可能ですか?使用する必要があることはわかっていますsetItem()
が、これを既存のマウスクリックイベントに関連付けるにはどうすればよいですか?
これが私がマウスクリックのために持っているイベントフィルターです:
def eventFilter(self, obj, event):
if obj is self.p1 and event.type() == event.GraphicsSceneMousePress:
if event.button()==Qt.LeftButton:
pos=event.scenePos()
x=((pos.x()*(2.486/96))-1)
y=(pos.y()*(10.28/512))
self.label.setText("x=%0.01f,y=%0.01f" %(x,y))
#here is where I get lost with creating an iterator to append to the table with each click
for row in range(10):
for column in range(2):
self.coordinates.setItem(row,column,(x,y))