”;
The QClipboard class provides access to system-wide clipboard that offers a simple mechanism to copy and paste data between applications. Its action is similar to QDrag class and uses similar data types.
QApplication class has a static method clipboard() which returns reference to clipboard object. Any type of MimeData can be copied to or pasted from the clipboard.
Following are the clipboard class methods that are commonly used −
Sr.No. | Methods & Description |
---|---|
1 |
clear() Clears clipboard contents |
2 |
setImage() Copies QImage into clipboard |
3 |
setMimeData() Sets MIME data into clipboard |
4 |
setPixmap() Copies Pixmap object in clipboard |
5 |
setText() Copies QString in clipboard |
6 |
text() Retrieves text from clipboard |
Signal associated with clipboard object is −
Sr.No. | Method & Description |
---|---|
1 |
dataChanged() Whenever clipboard data changes |
Example
In the following example, two TextEdit objects and two Pushbuttons are added to a top level window.
To begin with the clipboard object is instantiated. Copy() method of textedit object copies the data onto the system clipboard. When the Paste button is clicked, it fetches the clipboard data and pastes it in other textedit object.
”;