The QClipboard class provides access to the window system clipboard. More...
#include <qclipboard.h>
Inherits QObject.
The clipboard offers a simple mechanism to copy and paste data between applications.
QClipboard supports the same data types that QDragObject does, and uses similar mechanisms. For advanced clipboard usage, you should read the drag-and-drop documentation.
There is only one QClipboard object in an application, and you can gain access to it using QApplication::clipboard().
Example:
QClipboard *cb = QApplication::clipboard(); QString text; // Copy text from the clipboard (paste) text = cb->text(); if ( text ) qDebug( "The clipboard contains: %s", text ); // Copy text into the clipboard cb->setText( "This text can be pasted by other programs" );
QClipboard features some convenience functions to access common data types: The methods setText() allows exchanging unicode text easily over the clipboard, while setPixmap() setImage() allows to exchange QPixmap and QImage between applications. setData() is the ultimate in flexibility: It allows you to add any QMimeSource onto the clipboard. (There are corresponding getters for each of these, e.g. text().)
You can clear the clipboard by calling the method clear().
Clears the clipboard contents.
Returns a reference to a QMimeSource representation of the current clipboard data.
[signal]
This signal is emitted when the clipboard data is changed.
[virtual protected]
Reimplemented for internal reasons; the API is not affected.
Reimplemented from QObject.
Returns the clipboard image, or a null image if the clipboard does not contain an image, or if it contains an image in an unsupported image format.
See also setImage(), pixmap(), data() and QImage::isNull().
Returns the clipboard pixmap, or null if the clipboard does not contain any pixmap. Note that this can lose information - for example, if the image is 24-bit and the display 8-bit the result is converted to 8 bits, and if the image has an alpha channel the result just has a mask.
See also setPixmap(), image(), data() and QPixmap::convertFromImage().
Sets the clipboard data. Ownership of the data is transferred to the clipboard - the only ways to remove this data is to set something else, or to call clear(). The QDragObject subclasses are reasonable things to put on the clipboard (but do not try to call QDragObject::drag() on the same object). Any QDragObject placed in the clipboard should have a parent of 0. Do not put QDragMoveEvent or QDropEvent subclasses on the clipboard, as they do not belong to the event handler which receives them.
The setText() and setPixmap() functions are simpler wrappers for this.
Copies image into the clipboard.
This is shorthand for:
setData(new QImageDrag(image))
See also image(), setPixmap() and setData().
Copies pixmap into the clipboard. Note that this is slower than setImage() - it needs to convert the QPixmap to a QImage first.
See also pixmap(), setImage() and setData().
Copies text into the clipboard.
See also text() and setData().
Returns the clipboard as plain text, or a null string if the clipboard does not contain any text.
See also setText(), data() and QString::operator!().
Returns the clipboard text in subtype subtype, or a null string if the clipboard does not contain any text. If subtype is null, any subtype is acceptable, and subtype is set to the chosen subtype.
Common values for subtype are "plain" and "html".
See also setText(), data() and QString::operator!().
[virtual protected]
For internal use only.
Reimplemented from QObject.
Search the documentation, FAQ, qt-interest archive and more (uses
www.trolltech.com):
This file is part of the Qt toolkit, copyright © 1995-2000 Trolltech, all rights reserved.
Copyright İ 2000 Trolltech | Trademarks | Qt version 2.2.1
|