|  | Home · Overviews · Examples |

# QClipboard Class Reference
[com.trolltech.qt.gui module]

The QClipboard class provides access to the window system clipboard. More...

Inherits `QObject`.

## Detailed Description

The QClipboard class provides access to the window system clipboard.

The clipboard offers a simple mechanism to copy and paste data between applications.

QClipboard supports the same data types that `QDrag` does, and uses similar mechanisms. For advanced clipboard usage read Drag and Drop.

There is a single QClipboard object in an application, accessible as QApplication::clipboard().

Example:

        QClipboard *clipboard = QApplication::clipboard();
        QString originalText = clipboard->text();
        ...
        clipboard->setText(newText);

QClipboard features some convenience functions to access common data types: `setText` allows the exchange of Unicode text and `setPixmap` and `setImage` allows the exchange of QPixmaps and QImages between applications. The `setMimeData` function is the ultimate in flexibility: it allows you to add any `QMimeData` into the clipboard. There are corresponding getters for each of these, e.g. `text`, `image` and `pixmap`. You can clear the clipboard by calling `clear`.

### Notes for X11 Users

- The X11 Window System has the concept of a separate selection and clipboard. When text is selected, it is immediately available as the global mouse selection. The global mouse selection may later be copied to the clipboard. By convention, the middle mouse button is used to paste the global mouse selection.
- X11 also has the concept of ownership; if you change the selection within a window, X11 will only notify the owner and the previous owner of the change, i.e. it will not notify all applications that the selection or clipboard data changed.
- Lastly, the X11 clipboard is event driven, i.e. the clipboard will not function properly if the event loop is not running. Similarly, it is recommended that the contents of the clipboard are stored or retrieved in direct response to user-input events, e.g. mouse button or key presses and releases. You should not store or retrieve the clipboard contents in response to timer or non-user-input events.

### Notes for Mac OS X Users

Mac OS X supports a separate find buffer that holds the current search string in Find operations. This find clipboard can be accessed by specifying the `FindBuffer` mode.

### Notes for Windows and Mac OS X Users

- Windows and Mac OS X do not support the global mouse selection; they only supports the global clipboard, i.e. they only add text to the clipboard when an explicit copy or cut is made.
- Windows and Mac OS X does not have the concept of ownership; the clipboard is a fully global resource so all applications are notified of changes.

See also `QApplication`.