python里pos_试图仅获得“ x”。从pos()方法python进行协调

I'm currently having an issue getting just the x position of the cursor so I can place a marker on that x and y location. I'm using QGraphicsScene and view to create this circle object at the location of the mouse when the mouse is clicked. Since the QGraphicsEllipseItem takes 4 arguments it seems I need the x and y coordinate separate not just what the position method gives you since it gives both x and y. How do I split the two coordinates up? Here's the code:

import sys

from PyQt4 import QtGui, QtCore

def paintMarkers(self):

self.cursor = QtGui.QCursor()

self.x,y = self.cursor.pos()

self.circleItem = QtGui.QGraphicsEllipseItem(self.x,self.y,10,10)

self.scene.addItem(self.circleItem)

self.circleItem.setPen(QtGui.QPen(QtCore.Qt.red, 1.5))

self.setScene(self.scene)

def mousePressEvent(self,QMou

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值