English 中文(简体)
PyQt - QClipboard
  • 时间:2024-09-17

PyQt - QCppboard


Previous Page Next Page  

The QCppboard class provides access to system-wide cppboard that offers a simple mechanism to copy and paste data between apppcations. Its action is similar to QDrag class and uses similar data types.

QApppcation class has a static method cppboard() which returns reference to cppboard object. Any type of MimeData can be copied to or pasted from the cppboard.

Following are the cppboard class methods that are commonly used −

Sr.No. Methods & Description
1

clear()

Clears cppboard contents

2

setImage()

Copies QImage into cppboard

3

setMimeData()

Sets MIME data into cppboard

4

setPixmap()

Copies Pixmap object in cppboard

5

setText()

Copies QString in cppboard

6

text()

Retrieves text from cppboard

Signal associated with cppboard object is −

Sr.No. Method & Description
1

dataChanged()

Whenever cppboard data changes

Example

In the following example, two TextEdit objects and two Pushbuttons are added to a top level window.

To begin with the cppboard object is instantiated. Copy() method of textedit object copies the data onto the system cppboard. When the Paste button is cpcked, it fetches the cppboard data and pastes it in other textedit object.

QCppboard Output1 QCppboard Output2 QCppboard Output3 Advertisements