本文整理汇总了Python中PyQt5.QtCore.Qt.CopyAction方法的典型用法代码示例。如果您正苦于以下问题:Python Qt.CopyAction方法的具体用法?Python Qt.CopyAction怎么用?Python Qt.CopyAction使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt5.QtCore.Qt
的用法示例。
在下文中一共展示了Qt.CopyAction方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: mouseMoveEvent
# 需要导入模块: from PyQt5.QtCore import Qt [as 别名]
# 或者: from PyQt5.QtCore.Qt import CopyAction [as 别名]
def mouseMoveEvent(self, event):
if (event.buttons() == Qt.LeftButton and
(event.modifiers() == Qt.ControlModifier or
event.modifiers() == Qt.ShiftModifier)):
mime_data = QMimeData()
mime_data.setText(PageWidget.DRAG_MAGIC)
drag = QDrag(self)
drag.setMimeData(mime_data)
drag.setPixmap(self.grab(self.rect()))
if event.modifiers() == Qt.ControlModifier:
drag.exec_(Qt.MoveAction)
else:
drag.exec_(Qt.CopyAction)
event.accept()
else:
event.ignore()
示例2: mousePressEvent
# 需要导入模块: from PyQt5.QtCore import Qt [as 别名]
# 或者: from PyQt5.QtCore.Qt import CopyAction [as 别名]
def mousePressEvent(self, event):
child = self.childAt(event.pos())
if not child:
return
mimeData = QMimeData()
mimeData.setText(child.type)
logging.debug('mousePressEvent() called: {}'.format(event.pos()))
drag = QDrag(self)
drag.setPixmap(child.pixmap())
drag.setMimeData(mimeData)
drag.setHotSpot(event.pos() - child.pos())
if drag.exec_(Qt.CopyAction | Qt.MoveAction, Qt.CopyAction) == Qt.MoveAction:
child.close()
else:
child.show()
child.setPixmap(child.pixmap())
示例3: mousePressEvent
# 需要导入模块: from PyQt5.QtCore import Qt [as 别名]
# 或者: from PyQt5.QtCore.Qt import CopyAction [as 别名]
def mousePressEvent(self, event):
logging.debug('ElementMaster::mousePressEvent() called')
# uncomment this for debugging purpose
#self.listChild()
if event.buttons() != Qt.LeftButton:
return
icon = QLabel()
mimeData = QMimeData()
mime_text = str(self.row) + str(self.column) + str(self.__class__.__name__)
mimeData.setText(mime_text)
drag = QDrag(self)
drag.setMimeData(mimeData)
drag.setPixmap(self.pixmap)
drag.setHotSpot(event.pos() - self.rect().topLeft())
if drag.exec_(Qt.CopyAction | Qt.MoveAction, Qt.CopyAction) == Qt.MoveAction:
icon.close()
else:
icon.show()
icon.setPixmap(self.pixmap)
示例4: test_EditorPane_drop_event
# 需要导入模块: from PyQt5.QtCore import Qt [as 别名]
# 或者: from PyQt5.QtCore.Qt import CopyAction [as 别名]
def test_EditorPane_drop_event(qtapp):
"""
If there's a drop event associated with files, cause them to be passed into
Mu's existing file loading code.
"""
ep = mu.interface.editor.EditorPane(None, "baz")
m = mock.MagicMock()
ep.open_file = mock.MagicMock()
ep.open_file.emit = m
data = QMimeData()
data.setUrls(
[
QUrl("file://test/path.py"),
QUrl("file://test/path.hex"),
QUrl("file://test/path.txt"),
]
)
evt = QDropEvent(
QPointF(0, 0), Qt.CopyAction, data, Qt.LeftButton, Qt.NoModifier
)
ep.dropEvent(evt)
# Upstream _load will handle invalid file type (.txt).
assert m.call_count == 3
示例5: dropEvent
# 需要导入模块: from PyQt5.QtCore import Qt [as 别名]
# 或者: from PyQt5.QtCore.Qt import CopyAction [as 别名]
def dropEvent(self, event):
row, column = self._event_index(event)
if self.layout().itemAtPosition(row, column) is None:
if qApp.keyboardModifiers() == Qt.ControlModifier:
event.setDropAction(Qt.MoveAction)
event.accept()
self.move_drop_event.emit(event.source(), row, column)
elif qApp.keyboardModifiers() == Qt.ShiftModifier:
event.setDropAction(Qt.CopyAction)
self.copy_drop_event.emit(event.source(), row, column)
event.accept()
event.ignore()
示例6: mousePressEvent
# 需要导入模块: from PyQt5.QtCore import Qt [as 别名]
# 或者: from PyQt5.QtCore.Qt import CopyAction [as 别名]
def mousePressEvent(self, event):
# retrieve the label
child = self.childAt(event.pos())
if not child:
return
self.controller.mode = 'selection'
# update the creation mode to the appropriate subtype
self.controller.creation_mode = child.subtype
pixmap = QPixmap(child.pixmap().scaled(
QSize(50, 50),
Qt.KeepAspectRatio,
Qt.SmoothTransformation
))
mime_data = QtCore.QMimeData()
mime_data.setData('application/x-dnditemdata', QtCore.QByteArray())
drag = QtGui.QDrag(self)
drag.setMimeData(mime_data)
drag.setPixmap(pixmap)
drag.setHotSpot(event.pos() - child.pos() + QPoint(-3, -10))
if drag.exec_(Qt.CopyAction | Qt.MoveAction, Qt.CopyAction) == Qt.MoveAction:
child.close()
else:
child.show()
示例7: mousePressEvent
# 需要导入模块: from PyQt5.QtCore import Qt [as 别名]
# 或者: from PyQt5.QtCore.Qt import CopyAction [as 别名]
def mousePressEvent(self, event):
# retrieve the label
child = self.childAt(event.pos())
if not child:
return
self.controller.mode = 'selection'
# update the creation mode to the appropriate subtype
self.controller.creation_mode = child.subtype
# we change the view if necessary:
# if it is a site, we switch the site view
# if it is anything else and we are in the site view, we switch
# to the network view
if child.subtype == 'site':
self.project.show_site_view()
else:
if self.project.view_type == 'site':
self.project.show_network_view()
pixmap = QPixmap(child.pixmap().scaled(
QSize(50, 50),
Qt.KeepAspectRatio,
Qt.SmoothTransformation
))
mime_data = QtCore.QMimeData()
mime_data.setData('application/x-dnditemdata', QtCore.QByteArray())
drag = QtGui.QDrag(self)
drag.setMimeData(mime_data)
drag.setPixmap(pixmap)
drag.setHotSpot(event.pos() - child.pos() + QPoint(-3, -10))
if drag.exec_(Qt.CopyAction | Qt.MoveAction, Qt.CopyAction) == Qt.MoveAction:
child.close()
else:
child.show()
示例8: mousePressEvent
# 需要导入模块: from PyQt5.QtCore import Qt [as 别名]
# 或者: from PyQt5.QtCore.Qt import CopyAction [as 别名]
def mousePressEvent(self, event):
child = self.childAt(event.pos())
if not child:
return
pixmap = QPixmap(child.pixmap())
mimeData = QMimeData()
mimeData.setText(child.type)
drag = QDrag(self)
drag.setPixmap(child.pixmap())
drag.setMimeData(mimeData)
drag.setHotSpot(event.pos() - child.pos())
tempPixmap = QPixmap(pixmap)
painter = QPainter()
painter.begin(tempPixmap)
painter.fillRect(pixmap.rect(), QColor(127, 127, 127, 127))
painter.end()
child.setPixmap(tempPixmap)
if drag.exec_(Qt.CopyAction | Qt.MoveAction, Qt.CopyAction) == Qt.MoveAction:
child.close()
else:
child.show()
child.setPixmap(pixmap)
示例9: mousePressEvent
# 需要导入模块: from PyQt5.QtCore import Qt [as 别名]
# 或者: from PyQt5.QtCore.Qt import CopyAction [as 别名]
def mousePressEvent(self, event):
logging.debug('DropBox::mousePressEvent() called: {}'.format(event.pos()))
try:
mimeData = QMimeData()
mimeData.setText(self.type)
# load config into memory tmp_config of storabar
self.parent.tmp_config = self.config
self.parent.tmp_element = self
# push config to active workingarea
self.parent.loadConfig()
except Exception as e:
logging.error('DropBox::mousePressEvent() Exception caught: {}'.format(str(e)))
return
drag = QDrag(self)
drag.setHotSpot(event.pos())
drag.setPixmap(self.label.pixmap())
drag.setMimeData(mimeData)
if drag.exec_(Qt.CopyAction | Qt.MoveAction, Qt.CopyAction) == Qt.MoveAction:
self.close()
else:
self.show()
self.label.setPixmap(self.label.pixmap())
logging.debug('DropBox::mousePressEvent() dropped')
示例10: supportedDropActions
# 需要导入模块: from PyQt5.QtCore import Qt [as 别名]
# 或者: from PyQt5.QtCore.Qt import CopyAction [as 别名]
def supportedDropActions(self):
return Qt.CopyAction | Qt.MoveAction
示例11: add_all_signals_to_simulator
# 需要导入模块: from PyQt5.QtCore import Qt [as 别名]
# 或者: from PyQt5.QtCore.Qt import CopyAction [as 别名]
def add_all_signals_to_simulator(self):
assert isinstance(self.form, MainController)
sim_frame = self.form.simulator_tab_controller
sim_frame.ui.treeProtocols.selectAll()
self.assertGreater(len(sim_frame.ui.treeProtocols.selectedIndexes()), 0)
mimedata = sim_frame.tree_model.mimeData(sim_frame.ui.treeProtocols.selectedIndexes())
drop_event = QDropEvent(sim_frame.ui.gvSimulator.rect().center(), Qt.CopyAction | Qt.MoveAction,
mimedata, Qt.LeftButton, Qt.NoModifier)
drop_event.acceptProposedAction()
sim_frame.ui.gvSimulator.dropEvent(drop_event)
示例12: test_signal_view
# 需要导入模块: from PyQt5.QtCore import Qt [as 别名]
# 或者: from PyQt5.QtCore.Qt import CopyAction [as 别名]
def test_signal_view(self):
self.add_signal_to_form("esaver.complex16s")
signal = self.form.signal_tab_controller.signal_frames[0].signal
tree_view = self.dialog.ui.treeViewSignals
tree_model = tree_view.model()
item = tree_model.rootItem.children[0].children[0]
index = tree_model.createIndex(0, 0, item)
rect = tree_view.visualRect(index)
QTest.mousePress(tree_view.viewport(), Qt.LeftButton, pos=rect.center())
mime_data = tree_model.mimeData([index])
drag_drop = QDropEvent(rect.center(), Qt.CopyAction | Qt.MoveAction, mime_data, Qt.LeftButton, Qt.NoModifier)
drag_drop.acceptProposedAction()
self.dialog.ui.gVOriginalSignal.dropEvent(drag_drop)
self.assertEqual(self.dialog.ui.gVOriginalSignal.sceneRect().width(), signal.num_samples)
self.dialog.ui.cbShowDataBitsOnly.click()
self.dialog.ui.chkBoxLockSIV.click()
self.assertEqual(int(self.dialog.ui.gVOriginalSignal.view_rect().width()),
int(self.dialog.ui.gVModulated.view_rect().width()))
freq = self.dialog.ui.doubleSpinBoxCarrierFreq.value()
self.dialog.ui.btnAutoDetect.click()
self.assertNotEqual(freq, self.dialog.ui.doubleSpinBoxCarrierFreq.value())
self.dialog.ui.comboBoxModulationType.setCurrentText("Frequency Shift Keying (FSK)")
self.dialog.ui.btnAutoDetect.click()
self.assertEqual(self.dialog.ui.lCurrentSearchResult.text(), "1")
self.dialog.ui.btnSearchNext.click()
self.assertEqual(self.dialog.ui.lCurrentSearchResult.text(), "2")
self.dialog.ui.btnSearchPrev.click()
self.assertEqual(self.dialog.ui.lCurrentSearchResult.text(), "1")
示例13: dropEvent
# 需要导入模块: from PyQt5.QtCore import Qt [as 别名]
# 或者: from PyQt5.QtCore.Qt import CopyAction [as 别名]
def dropEvent(self, event):
"""
Run by Qt when *something* is dropped on this editor
"""
# Does the drag event have any urls?
# Files are transfered as a url (by path not value)
if event.mimeData().hasUrls():
# Qt doesn't seem to have an 'open' action,
# this seems the most appropriate
event.setDropAction(Qt.CopyAction)
# Valid links
links = []
# Iterate over each of the urls attached to the event
for url in event.mimeData().urls():
# Check the url is to a local file
# (not a webpage for example)
if url.isLocalFile():
# Grab a 'real' path from the url
path = url.toLocalFile()
# Add it to the list of valid links
links.append(path)
# Did we get any?
if len(links) > 0:
# Only accept now we actually know we can do
# something with the drop event
event.accept()
for link in links:
# Start bubbling an open file request
self.open_file.emit(link)
# If the event wasn't handled let QsciScintilla have a go
if not event.isAccepted():
super().dropEvent(event)