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 −
Signal associated with clipboard object is −
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.
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 −
S.No. | Methods & Description |
---|---|
1 |
clear() Clears clipboard contents |
2 |
setImage() Copies QImage into clipboard |
3 |
setMimeData() Sets MIME data into clipbopard |
4 |
setPixmap() Copies Pixmap object in clipboard |
5 |
setText() Copies QString in clipboard |
6 |
text() Retrieves text from clipboard |
S.No. | Method & Description |
---|---|
1 |
dataChanged() Whenever clipboard data changes |
Example
In the following example, two TextEdit objects and two Pushbutons 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.
No comments:
Post a Comment