当前位置: 首页>>代码示例>>Python>>正文


Python QMimeData.setText方法代码示例

本文整理汇总了Python中PyQt5.QtCore.QMimeData.setText方法的典型用法代码示例。如果您正苦于以下问题:Python QMimeData.setText方法的具体用法?Python QMimeData.setText怎么用?Python QMimeData.setText使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PyQt5.QtCore.QMimeData的用法示例。


在下文中一共展示了QMimeData.setText方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: mouseMoveEvent

# 需要导入模块: from PyQt5.QtCore import QMimeData [as 别名]
# 或者: from PyQt5.QtCore.QMimeData import setText [as 别名]
 def mouseMoveEvent(self, event):
     """
     Protected method to handle mouse move events.
     
     @param event reference to the mouse move event (QMouseEvent)
     """
     if event.buttons() == Qt.MouseButtons(Qt.LeftButton) and \
        (event.pos() - self.__dragStartPos).manhattanLength() > \
             QApplication.startDragDistance():
         drag = QDrag(self)
         mimeData = QMimeData()
         index = self.tabAt(event.pos())
         mimeData.setText(self.tabText(index))
         mimeData.setData("action", b"tab-reordering")
         mimeData.setData("tabbar-id", str(id(self)).encode("utf-8"))
         mimeData.setData(
             "source-index",
             QByteArray.number(self.tabAt(self.__dragStartPos)))
         mimeData.setData(
             "tabwidget-id",
             str(id(self.parentWidget())).encode("utf-8"))
         drag.setMimeData(mimeData)
         if event.modifiers() == Qt.KeyboardModifiers(Qt.ShiftModifier):
             drag.exec_(Qt.DropActions(Qt.CopyAction))
         elif event.modifiers() == Qt.KeyboardModifiers(Qt.NoModifier):
             drag.exec_(Qt.DropActions(Qt.MoveAction))
     super(TabBar, self).mouseMoveEvent(event)
开发者ID:paulmadore,项目名称:Eric-IDE,代码行数:29,代码来源:Tabview.py

示例2: mouseMoveEvent

# 需要导入模块: from PyQt5.QtCore import QMimeData [as 别名]
# 或者: from PyQt5.QtCore.QMimeData import setText [as 别名]
    def mouseMoveEvent(self, event):
        if QLineF(QPointF(event.screenPos()), QPointF(event.buttonDownScreenPos(Qt.LeftButton))).length() < QApplication.startDragDistance():
            return

        drag = QDrag(event.widget())
        mime = QMimeData()
        drag.setMimeData(mime)

        ColorItem.n += 1
        if ColorItem.n > 2 and qrand() % 3 == 0:
            image = QImage(':/images/head.png')
            mime.setImageData(image)
            drag.setPixmap(QPixmap.fromImage(image).scaled(30,40))
            drag.setHotSpot(QPoint(15, 30))
        else:
            mime.setColorData(self.color)
            mime.setText("#%02x%02x%02x" % (self.color.red(), self.color.green(), self.color.blue()))

            pixmap = QPixmap(34, 34)
            pixmap.fill(Qt.white)

            painter = QPainter(pixmap)
            painter.translate(15, 15)
            painter.setRenderHint(QPainter.Antialiasing)
            self.paint(painter, None, None)
            painter.end()

            pixmap.setMask(pixmap.createHeuristicMask())

            drag.setPixmap(pixmap)
            drag.setHotSpot(QPoint(15, 20))

        drag.exec_()
        self.setCursor(Qt.OpenHandCursor)
开发者ID:CarlosAndres12,项目名称:pyqt5,代码行数:36,代码来源:dragdroprobot.py

示例3: copy

# 需要导入模块: from PyQt5.QtCore import QMimeData [as 别名]
# 或者: from PyQt5.QtCore.QMimeData import setText [as 别名]
 def copy(self):
     """Copy to the clipboard"""
     data = QMimeData()
     text = '\n'.join([cursor.selectedText() \
                         for cursor in self.cursors()])
     data.setText(text)
     data.setData(self.MIME_TYPE, text.encode('utf8'))
     QApplication.clipboard().setMimeData(data)
开发者ID:Aldenis2112,项目名称:qutepart,代码行数:10,代码来源:rectangularselection.py

示例4: mimeData

# 需要导入模块: from PyQt5.QtCore import QMimeData [as 别名]
# 或者: from PyQt5.QtCore.QMimeData import setText [as 别名]
 def mimeData(self, idxs):
     mdata = QMimeData()
     nodes = []
     for idx in idxs:
         item = self.itemFromIndex(idx)
         if item:
             node = item.data()
             if node:
                 nodes.append(node.nodeid.to_string())
     mdata.setText(", ".join(nodes))
     return mdata
开发者ID:lavstudia,项目名称:opcua-client-gui,代码行数:13,代码来源:mainwindow.py

示例5: mimeData

# 需要导入模块: from PyQt5.QtCore import QMimeData [as 别名]
# 或者: from PyQt5.QtCore.QMimeData import setText [as 别名]
 def mimeData(self, indexes):
     data = ''
     for index in indexes:
         parent_item = self.getItem(index.parent())
         if parent_item == self.rootItem:
             data += "{0},{1},{2}/".format(index.row(), index.column(), -1)
         else:
             data += "{0},{1},{2}/".format(index.row(), index.column(), self.rootItem.index_of(parent_item))
     mime_data = QMimeData()
     mime_data.setText(data)
     return mime_data
开发者ID:jopohl,项目名称:urh,代码行数:13,代码来源:ProtocolTreeModel.py

示例6: mouseMoveEvent

# 需要导入模块: from PyQt5.QtCore import QMimeData [as 别名]
# 或者: from PyQt5.QtCore.QMimeData import setText [as 别名]
 def mouseMoveEvent(self, e):
     modifiers = QApplication.keyboardModifiers()
     if modifiers == Qt.ControlModifier:
         mimeData = QMimeData()
         drag = QDrag(e.widget())
         mimeData.setText("node")
         drag.setMimeData(mimeData)
         drag.exec_(Qt.MoveAction)
         self.ungrabMouse()
     if self.edgeInConstruction != None:
         self.edgeInConstruction.obsUpdate(e.scenePos())
开发者ID:MatthieuDien,项目名称:DotEd,代码行数:13,代码来源:node.py

示例7: insertFromMimeData

# 需要导入模块: from PyQt5.QtCore import QMimeData [as 别名]
# 或者: from PyQt5.QtCore.QMimeData import setText [as 别名]
 def insertFromMimeData(self, source):
     """Remove newlines from pasted text if necessary."""
     if self.single_line:
         # Remove newlines.
         text = source.text()
         mime = QMimeData()
         # TODO:  does windows+mac work?    
         mime.setText(text.replace("\n", " "))
     else:
         mime = source
     super().insertFromMimeData(mime)
开发者ID:t-brink,项目名称:pscic,代码行数:13,代码来源:inputwidget.py

示例8: mousePressEvent

# 需要导入模块: from PyQt5.QtCore import QMimeData [as 别名]
# 或者: from PyQt5.QtCore.QMimeData import setText [as 别名]
    def mousePressEvent(self, event):
        if event.button() == Qt.LeftButton:
            self.drag_started.emit(self.mapToParent(event.pos()))
            drag = QDrag(self)
            mimeData = QMimeData()
            mimeData.setText("Move Signal")
            pixmap = QPixmap(self.rect().size())
            self.render(pixmap, QPoint(), QRegion(self.rect()))
            drag.setPixmap(pixmap)

            drag.setMimeData(mimeData)

            drag.exec_()
开发者ID:Cyber-Forensic,项目名称:urh,代码行数:15,代码来源:SignalFrameController.py

示例9: mimeData

# 需要导入模块: from PyQt5.QtCore import QMimeData [as 别名]
# 或者: from PyQt5.QtCore.QMimeData import setText [as 别名]
    def mimeData(self, indexes):
        # Create MimeData for drag operation
        data = QMimeData()

        # Get list of all selected file ids
        property_names = []
        for item in indexes:
            selected_row = self.itemFromIndex(item).row()
            property_names.append(self.item(selected_row, 0).data())
        data.setText(json.dumps(property_names))

        # Return Mimedata
        return data
开发者ID:ghisvail,项目名称:openshot-qt,代码行数:15,代码来源:properties_model.py

示例10: mimeData

# 需要导入模块: from PyQt5.QtCore import QMimeData [as 别名]
# 或者: from PyQt5.QtCore.QMimeData import setText [as 别名]
    def mimeData(self, indexes):
        """
        This is a single-selection model, so there should only be
        one row getting dragged.

        And what we're dragging around is simply a text version of
        the inode for the dragged file.
        :param indexes:
        :return:
        """
        mimedata = QMimeData()
        mimedata.setText(str(indexes[0].internalId()))
        return mimedata
开发者ID:Kf4btg,项目名称:SkyModMan,代码行数:15,代码来源:archivefs_treemodel.py

示例11: mouseMoveEvent

# 需要导入模块: from PyQt5.QtCore import QMimeData [as 别名]
# 或者: from PyQt5.QtCore.QMimeData import setText [as 别名]
 def mouseMoveEvent(self, event):
     if not event.buttons() and Qt.LeftButton:
         return
     distance = (event.pos() - self.start_mouse_drag).manhattanLength()
     if distance < QApplication.startDragDistance():
         return
     item = self.selectedItems()[0]
     text = "<row>" + str(item.row()) + "<row>" + "<col>" + str(item.column()) + "<col>" + "<text>" + str(item.text()) + "<text>"
     print(text)
     drag = QDrag(self)
     mim_data = QMimeData()
     mim_data.setText(text)
     drag.setMimeData(mim_data)
     dropAction = drag.exec_(Qt.MoveAction)
开发者ID:Meller008,项目名称:CRM-Avi,代码行数:16,代码来源:table_widget_dad.py

示例12: mimeData

# 需要导入模块: from PyQt5.QtCore import QMimeData [as 别名]
# 或者: from PyQt5.QtCore.QMimeData import setText [as 别名]
    def mimeData(self, indexes):
        # Create MimeData for drag operation
        data = QMimeData()

        # Get list of all selected file ids
        files = []
        for item in indexes:
            selected_row = self.itemFromIndex(item).row()
            files.append(self.item(selected_row, 4).text())
        data.setText(json.dumps(files))
        data.setHtml("effect")

        # Return Mimedata
        return data
开发者ID:OpenShot,项目名称:openshot-qt,代码行数:16,代码来源:effects_model.py

示例13: mouseMoveEvent

# 需要导入模块: from PyQt5.QtCore import QMimeData [as 别名]
# 或者: from PyQt5.QtCore.QMimeData import setText [as 别名]
    def mouseMoveEvent(self, event):
        if event.buttons() & Qt.LeftButton:
            index = self._findEventIndex(event)
            if self._maybeDragPosition is not None:
                if ((event.pos() - self._maybeDragPosition).manhattanLength()
                        < QApplication.startDragDistance()):
                        return
                # TODO: needs ordering or not?
                glyphList = " ".join(
                    glyph.name for glyph in self.getSelectedGlyphs())
                drag = QDrag(self)
                mimeData = QMimeData()
                mimeData.setText(glyphList)
                drag.setMimeData(mimeData)

                drag.exec_()
                self._maybeDragPosition = None
                event.accept()
                return
            if index == self._lastSelectedCell:
                return

            modifiers = event.modifiers()
            event.accept()
            if index is None:
                if not (modifiers & Qt.ControlModifier or
                        modifiers & Qt.ShiftModifier):
                    self.selection = set()
                self._lastSelectedCell = index
                return
            if modifiers & Qt.ControlModifier:
                if index in self._selection and index in self._oldSelection:
                    selection = self.selection
                    selection.remove(index)
                    self.selection = selection
                elif (index not in self._selection and
                      index not in self._oldSelection):
                    selection = self.selection
                    selection.add(index)
                    self.selection = selection
            elif modifiers & Qt.ShiftModifier:
                newSelection = self._linearSelection(index)
                if newSelection is not None:
                    self.selection = newSelection
            else:
                self.selection = {index}
            self.lastSelectedCell = index
        else:
            super(GlyphCollectionWidget, self).mouseMoveEvent(event)
开发者ID:adrientetar,项目名称:trufont,代码行数:51,代码来源:glyphCollectionView.py

示例14: mimeData

# 需要导入模块: from PyQt5.QtCore import QMimeData [as 别名]
# 或者: from PyQt5.QtCore.QMimeData import setText [as 别名]
    def mimeData(self, indexes):
        """

        :param list[QModelIndex] indexes:
        :return: A string that is 2 ints separated by whitespace, e.g.:  '4 8' This string corresponds to the first and last row in the block of rows being dragged.
        """
        rows = sorted(set(i.row() for i in indexes))

        # save these as ints to speed up canDropMimeData
        self._drag_start = rows[0]
        self._drag_end = rows[-1]

        mimedata = QMimeData()
        mimedata.setText("{0._drag_start} {0._drag_end}".format(self))
        return mimedata
开发者ID:Kf4btg,项目名称:SkyModMan,代码行数:17,代码来源:modtable_treemodel.py

示例15: mouseMoveEvent

# 需要导入模块: from PyQt5.QtCore import QMimeData [as 别名]
# 或者: from PyQt5.QtCore.QMimeData import setText [as 别名]
 def mouseMoveEvent(self, event):
     """
     Protected method to handle mouse move events.
     
     @param event reference to the mouse move event (QMouseEvent)
     """
     if event.buttons() == Qt.MouseButtons(Qt.LeftButton) and \
        (event.pos() - self.__dragStartPos).manhattanLength() > \
             QApplication.startDragDistance():
         drag = QDrag(self)
         mimeData = QMimeData()
         index = self.tabAt(event.pos())
         mimeData.setText(self.tabText(index))
         mimeData.setData("action", "tab-reordering")
         mimeData.setData("tabbar-id", str(id(self)))
         drag.setMimeData(mimeData)
         drag.exec_()
     E5WheelTabBar.mouseMoveEvent(self, event)
开发者ID:Darriall,项目名称:eric,代码行数:20,代码来源:E5TabWidget.py


注:本文中的PyQt5.QtCore.QMimeData.setText方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。