本文整理匯總了Python中PyQt5.QtGui.QCursor.pos方法的典型用法代碼示例。如果您正苦於以下問題:Python QCursor.pos方法的具體用法?Python QCursor.pos怎麽用?Python QCursor.pos使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類PyQt5.QtGui.QCursor
的用法示例。
在下文中一共展示了QCursor.pos方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: getDetailInfo
# 需要導入模塊: from PyQt5.QtGui import QCursor [as 別名]
# 或者: from PyQt5.QtGui.QCursor import pos [as 別名]
def getDetailInfo(self):
"""點擊後進行動畫效果的: 顯示某歌曲的詳細信息。"""
self.shortInfo.hide()
self.detailInfo.show()
self.showDetail = QPropertyAnimation(self, b"geometry")
x = self.pos().x()
y = self.pos().y()
self.showDetail.setStartValue(QRect(x, y, self.width(), self.height()))
# 獲取頂層父窗口的長度。
self.showDetail.setEndValue(QRect(0, self.grandparent.header.height()+3, self.grandparent.width(), self.grandparent.mainContent.height()))
self.showDetail.setDuration(300)
self.showDetail.setEasingCurve(QEasingCurve.InBack)
self.showDetail.start(QAbstractAnimation.DeleteWhenStopped)
# 將該組件顯示在最前,默認會嵌入到父組件裏麵。
self.raise_()
self.setDetailInfo()
示例2: getShortInfo
# 需要導入模塊: from PyQt5.QtGui import QCursor [as 別名]
# 或者: from PyQt5.QtGui.QCursor import pos [as 別名]
def getShortInfo(self):
"""返回到原來的縮略圖信息。"""
self.detailInfo.hide()
self.showShort = QPropertyAnimation(self, b"geometry")
x = self.pos().x()
y = self.pos().y()
self.showShort.setStartValue(QRect(0, self.grandparent.header.height(), self.grandparent.width(), self.grandparent.mainContent.height()))
self.showShort.setEndValue(QRect(0, self.grandparent.height()-64-self.parent.height(), self.grandparent.navigation.width(), 64))
self.showShort.setDuration(300)
self.showShort.setEasingCurve(QEasingCurve.InBack)
self.showShort.start(QAbstractAnimation.DeleteWhenStopped)
self.shortInfo.show()
self.raise_()
示例3: downloadWidgetContext
# 需要導入模塊: from PyQt5.QtGui import QCursor [as 別名]
# 或者: from PyQt5.QtGui.QCursor import pos [as 別名]
def downloadWidgetContext(self, point):
"""downloadWidget right click menu
"""
popMenu = QMenu()
startAThread = QAction('開始', self)
pauseAThread = QAction('暫停', self)
clearAThread = QAction('刪除', self)
startAThread.triggered.connect(lambda: self.operateAThread(1, point))
pauseAThread.triggered.connect(lambda: self.operateAThread(2, point))
clearAThread.triggered.connect(lambda: self.operateAThread(3, point))
popMenu.addAction(startAThread)
popMenu.addAction(pauseAThread)
popMenu.addAction(clearAThread)
popMenu.exec_(QCursor.pos())
示例4: contextMenuEvent
# 需要導入模塊: from PyQt5.QtGui import QCursor [as 別名]
# 或者: from PyQt5.QtGui.QCursor import pos [as 別名]
def contextMenuEvent(self, event: QContextMenuEvent) -> None:
col = self.columnAt(event.pos().x())
row = self.rowAt(event.pos().y())
if col == 3:
item = self.item(row, col)
vtype = item.value_type
if vtype != "unknown":
menu = QMenu(self)
as_int = QAction("repr as int", self)
as_int.triggered.connect(lambda: self.repr_as_int(row, col))
as_hex = QAction("repr as hex", self)
as_hex.triggered.connect(lambda: self.repr_as_hex(row, col))
as_flt = QAction("repr as floating", self)
as_flt.triggered.connect(lambda: self.repr_as_floating(row, col))
as_str = QAction("repr as str", self)
as_str.triggered.connect(lambda: self.repr_as_str(row, col))
as_bys = QAction("repr as bytes", self)
as_bys.triggered.connect(lambda: self.repr_as_bytes(row, col))
menu.addAction(as_int)
menu.addAction(as_hex)
menu.addAction(as_flt)
menu.addAction(as_str)
menu.addAction(as_bys)
menu.popup(QCursor.pos())
示例5: mouseMoveEvent
# 需要導入模塊: from PyQt5.QtGui import QCursor [as 別名]
# 或者: from PyQt5.QtGui.QCursor import pos [as 別名]
def mouseMoveEvent(self, event):
super(ChartView, self).mouseMoveEvent(event)
# 把鼠標位置所在點轉換為對應的xy值
x = self._chart.mapToValue(event.pos()).x()
y = self._chart.mapToValue(event.pos()).y()
index = round((x - self.min_x) / self.step_x)
# print(x, pos_x, index, index * self.step_x + self.min_x)
# 得到在坐標係中的所有series的類型和點
points = [(serie, serie.at(index))
for serie in self._chart.series() if self.min_x <= x <= self.max_x and self.min_y <= y <= self.max_y]
if points:
# 跟隨鼠標的黑線條
self.lineItem.setLine(event.pos().x(), self.point_top.y(),
event.pos().x(), self.point_bottom.y())
self.lineItem.show()
self.toolTipWidget.show("", points, event.pos() + QPoint(20, 20))
else:
self.toolTipWidget.hide()
self.lineItem.hide()
示例6: mouseMoveEvent
# 需要導入模塊: from PyQt5.QtGui import QCursor [as 別名]
# 或者: from PyQt5.QtGui.QCursor import pos [as 別名]
def mouseMoveEvent(self, event):
super(ChartView, self).mouseMoveEvent(event)
# 把鼠標位置所在點轉換為對應的xy值
x = self._chart.mapToValue(event.pos()).x()
y = self._chart.mapToValue(event.pos()).y()
index = round((x - self.min_x) / self.step_x)
pos_x = self._chart.mapToPosition(
QPointF(index * self.step_x + self.min_x, self.min_y))
# print(x, pos_x, index, index * self.step_x + self.min_x)
# 得到在坐標係中的所有series的類型和點
points = [(serie, serie.at(index))
for serie in self._chart.series() if self.min_x <= x <= self.max_x and self.min_y <= y <= self.max_y]
if points:
# 永遠在軸上的黑線條
self.lineItem.setLine(pos_x.x(), self.point_top.y(),
pos_x.x(), self.point_bottom.y())
self.lineItem.show()
self.toolTipWidget.show("", points, event.pos() + QPoint(20, 20))
else:
self.toolTipWidget.hide()
self.lineItem.hide()
示例7: paintEvent
# 需要導入模塊: from PyQt5.QtGui import QCursor [as 別名]
# 或者: from PyQt5.QtGui.QCursor import pos [as 別名]
def paintEvent(self, event):
super(Label, self).paintEvent(event)
# 中正間畫十字
painter = QPainter(self)
painter.setPen(Qt.red)
x = int(self.width() / 2)
y = int(self.height() / 2)
painter.drawLine(x, 0, x, self.height())
painter.drawLine(0, y, self.width(), y)
if self.ismd:
# 畫坐標點
pos = QCursor.pos()
ret = win32gui.GetPixel(win32gui.GetWindowDC(
win32gui.GetDesktopWindow()), pos.x(), pos.y())
r, g, b = ret & 0xff, (ret >> 8) & 0xff, (ret >> 16) & 0xff
print(r, g, b)
painter.setPen(Qt.white)
painter.drawText(self.rect(), Qt.AlignLeft |
Qt.AlignBottom, '({}, {})\nRGB: ({}, {}, {})\n{}'.format(
pos.x(), pos.y(), r, g, b, QColor(r, g, b).name()))
示例8: startDrag
# 需要導入模塊: from PyQt5.QtGui import QCursor [as 別名]
# 或者: from PyQt5.QtGui.QCursor import pos [as 別名]
def startDrag(self, supportedActions):
items = self.selectedItems()
drag = QDrag(self)
mimeData = self.mimeData(items)
# 由於QMimeData隻能設置image、urls、str、bytes等等不方便
# 這裏添加一個額外的屬性直接把item放進去,後麵可以根據item取出數據
mimeData.setProperty('myItems', items)
drag.setMimeData(mimeData)
pixmap = QPixmap(self.viewport().visibleRegion().boundingRect().size())
pixmap.fill(Qt.transparent)
painter = QPainter()
painter.begin(pixmap)
for item in items:
rect = self.visualRect(self.indexFromItem(item))
painter.drawPixmap(rect, self.viewport().grab(rect))
painter.end()
drag.setPixmap(pixmap)
drag.setHotSpot(self.viewport().mapFromGlobal(QCursor.pos()))
drag.exec_(supportedActions)
示例9: zoom
# 需要導入模塊: from PyQt5.QtGui import QCursor [as 別名]
# 或者: from PyQt5.QtGui.QCursor import pos [as 別名]
def zoom(self, factor, zoom_to_mouse_cursor=True, cursor_pos=None):
if factor > 1 and self.view_rect().width() / factor < self.MINIMUM_VIEW_WIDTH:
factor = self.view_rect().width() / self.MINIMUM_VIEW_WIDTH
if zoom_to_mouse_cursor:
pos = self.mapFromGlobal(QCursor.pos()) if cursor_pos is None else cursor_pos
else:
pos = None
old_pos = self.mapToScene(pos) if pos is not None else None
show_full = False
if self.view_rect().width() / factor > self.sceneRect().width():
self.show_full_scene()
factor = 1
show_full = True
self.scale(factor, 1)
if show_full:
self.zoomed.emit(-1)
else:
self.zoomed.emit(factor)
if pos is not None:
move = self.mapToScene(pos) - old_pos
self.translate(move.x(), 0)
示例10: contextMenuEvent
# 需要導入模塊: from PyQt5.QtGui import QCursor [as 別名]
# 或者: from PyQt5.QtGui.QCursor import pos [as 別名]
def contextMenuEvent(self, event):
"""Pops up the context menu when the right button is clicked."""
try:
index = self._get_current_index
menu = RCMenu(self)
menu.popup(QCursor.pos())
self.selected_indexes = menu.return_selected_row_indexes()
menu.overall_hist_action.triggered.connect(
self._compute_overall_histograms)
except UnboundLocalError:
pass
示例11: download_clicked
# 需要導入模塊: from PyQt5.QtGui import QCursor [as 別名]
# 或者: from PyQt5.QtGui.QCursor import pos [as 別名]
def download_clicked(self):
click_me = qApp.focusWidget()
index = self.indexAt(click_me.pos())
if index.isValid():
row = index.row()
if sys.version_info[0] == 2:
docid = convert_str(self.item(row, 1).text())
else:
docid = self.item(row, 1).text()
self.set_status(row, 0)
self.indexes[docid] = row
self.added_new_doc.emit([docid])
示例12: __add_items_to_plot
# 需要導入模塊: from PyQt5.QtGui import QCursor [as 別名]
# 或者: from PyQt5.QtGui.QCursor import pos [as 別名]
def __add_items_to_plot(self, len_plot, min_audio, max_audio):
"""
Adds a region selector item and vertical line for to the waveform plot.
:param len_plot: (int) Number of samples in plotted waveform array.
:param min_audio: (float) The minimum value of plotted waveform array.
:param max_audio: (float) The maximum value of plotted waveform array.
"""
# Create a waveform region item and add it to waveform plot
pos_wf_x_max = len_plot * 0.05 # Region item focuses on the 5% of
# waveform plot.
self.region_wf = WaveformRegionItem(values=[0, pos_wf_x_max],
brush=WAVEFORM_BRUSH,
bounds=[0., len_plot])
# Creating a cursor with pyqtgraph.ROI
self.vline_wf = pg.ROI(pos=[0, min_audio],
size=[0, max_audio - min_audio],
angle=0, pen=WAVEFORM_VLINE)
# add items to waveform plot
self.waveform.addItem(self.region_wf)
self.waveform.addItem(self.vline_wf)
# text item
self.section_label = pg.TextItem(text='')
self.waveform.addItem(self.section_label)
示例13: update_wf_vline
# 需要導入模塊: from PyQt5.QtGui import QCursor [as 別名]
# 或者: from PyQt5.QtGui.QCursor import pos [as 別名]
def update_wf_vline(self, playback_pos_sample):
"""
Updated the position of vertical line.
:param playback_pos_sample: (int) Position of playback in samples.
"""
pos = playback_pos_sample / self.ratio
if pos <= 0:
pos = 0
elif pos >= self.len:
pos = self.len
self.vline_wf.setPos([pos, self.min])
示例14: contextMenuEvent
# 需要導入模塊: from PyQt5.QtGui import QCursor [as 別名]
# 或者: from PyQt5.QtGui.QCursor import pos [as 別名]
def contextMenuEvent(self, event):
self.tablewidget_menu.popup(QCursor.pos())
# CategoryTreeView Class adds QMenu to QTreeView
示例15: mousePressEvent
# 需要導入模塊: from PyQt5.QtGui import QCursor [as 別名]
# 或者: from PyQt5.QtGui.QCursor import pos [as 別名]
def mousePressEvent(self, event):
self.mousePos = QCursor.pos()