本文整理匯總了Python中PyQt5.Qt.QCursor類的典型用法代碼示例。如果您正苦於以下問題:Python QCursor類的具體用法?Python QCursor怎麽用?Python QCursor使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了QCursor類的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: show_context_menu
def show_context_menu(self, point):
item = self.currentItem()
def key(k):
sc = unicode_type(QKeySequence(k | Qt.CTRL).toString(QKeySequence.NativeText))
return ' [%s]'%sc
if item is not None:
m = QMenu()
m.addAction(QIcon(I('edit_input.png')), _('Change the location this entry points to'), self.edit_item)
m.addAction(QIcon(I('modified.png')), _('Bulk rename all selected items'), self.bulk_rename)
m.addAction(QIcon(I('trash.png')), _('Remove all selected items'), self.del_items)
m.addSeparator()
ci = unicode_type(item.data(0, Qt.DisplayRole) or '')
p = item.parent() or self.invisibleRootItem()
idx = p.indexOfChild(item)
if idx > 0:
m.addAction(QIcon(I('arrow-up.png')), (_('Move "%s" up')%ci)+key(Qt.Key_Up), self.move_up)
if idx + 1 < p.childCount():
m.addAction(QIcon(I('arrow-down.png')), (_('Move "%s" down')%ci)+key(Qt.Key_Down), self.move_down)
if item.parent() is not None:
m.addAction(QIcon(I('back.png')), (_('Unindent "%s"')%ci)+key(Qt.Key_Left), self.move_left)
if idx > 0:
m.addAction(QIcon(I('forward.png')), (_('Indent "%s"')%ci)+key(Qt.Key_Right), self.move_right)
m.addSeparator()
case_menu = QMenu(_('Change case'))
case_menu.addAction(_('Upper case'), self.upper_case)
case_menu.addAction(_('Lower case'), self.lower_case)
case_menu.addAction(_('Swap case'), self.swap_case)
case_menu.addAction(_('Title case'), self.title_case)
case_menu.addAction(_('Capitalize'), self.capitalize)
m.addMenu(case_menu)
m.exec_(QCursor.pos())
示例2: show_context_menu
def show_context_menu(self, point):
idx = self.currentIndex()
if idx and idx.isValid() and not idx.data(Qt.UserRole):
m = QMenu()
m.addAction(QIcon(I('view.png')), _('View this cover at full size'), self.show_cover)
m.addAction(QIcon(I('edit-copy.png')), _('Copy this cover to clipboard'), self.copy_cover)
m.exec_(QCursor.pos())
示例3: workaround_broken_under_mouse
def workaround_broken_under_mouse(ch):
import sip
from PyQt5.Qt import QCursor, QToolButton
# See https://bugreports.qt-project.org/browse/QTBUG-40233
if isinstance(ch, QToolButton) and not sip.isdeleted(ch):
ch.setAttribute(Qt.WA_UnderMouse, ch.rect().contains(ch.mapFromGlobal(QCursor.pos())))
ch.update()
示例4: exec
def exec(self, x = None, y = None):
if x is None:
super(Menu, self).exec(QCursor.pos())
else:
super(Menu, self).exec(QPoint(x, y))
示例5: sample_direction
def sample_direction(self,time_):
if len(self.mouse_positions)>1:
self.mouse_positions[time_]=QCursor.pos()
示例6: sample_pos
def sample_pos(self,time_):
self.mouse_positions[time_]=QCursor.pos()
示例7: collapse_menu_hovered
def collapse_menu_hovered(self, action):
tip = action.toolTip()
if tip == '*':
tip = ''
QToolTip.showText(QCursor.pos(), tip)
示例8: contextMenuEvent
def contextMenuEvent(self, event):
"""右鍵點擊事件"""
self._menu.popup(QCursor.pos())