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|
Clears clipboard contents
Copies QImage into clipboard
Sets MIME data into clipboard
Copies Pixmap object in clipboard
Copies QString in clipboard
Retrieves text from clipboard
Signal associated with clipboard object is −
|Sr.No.||Method & Description|
Whenever clipboard data changes
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.