Qt logo

QClipboard Class Reference


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

#include <qclipboard.h>

Inherits QObject.

List of all member functions.

Public Members

Signals

Protected Members


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 formats that drag and drop supports, and uses much of the same mechanisms.

Only a single QClipboard object may exist in an application. This is because QClipboard is a shared window system resource. Call QApplication::clipboard() to access the 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" );

Member Function Documentation

void QClipboard::clear ()

Clears the clipboard contents.

void QClipboard::connectNotify ( const char * ) [virtual protected]

For internal use only.

Reimplemented from QObject.

QMimeSourceQClipboard::data () const

Returns a reference to a QMimeSource representation of the current clipboard data.

void QClipboard::dataChanged () [signal]

This signal is emitted when the clipboard data is changed.

bool QClipboard::event ( QEvent * e ) [virtual protected]

Handles clipboard events (very platform-specific).

Reimplemented from QObject.

QImage QClipboard::image () const

Returns the clipboard image, or null if the clipboard does not contain an image.

See also: setText().

QPixmap QClipboard::pixmap () const

Returns the clipboard pixmap, or null if the clipboard does not contains any pixmap. Note that this usually looses more information than image().

See also: setText() and image().

void QClipboard::setData ( QMimeSource * src )

Sets the clipboard data. Ownership of the data is transferred to the clipboard - the only way 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 drag the same object). 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 shorthand ways of setting the data.

void QClipboard::setImage ( const QImage & image )

Copies image into the clipboard.

This is just a shorthand for:

    setData(new QImageDrag(image))

See also: image() and setData().

void QClipboard::setPixmap ( const QPixmap & pixmap )

Copies pixmap into the clipboard. Note that this usually looses more information than setImage(), as the data may be converted to an image for transfer.

See also: pixmap().

void QClipboard::setText ( const QString & text )

Copies text into the clipboard.

See also: text() and setData().

QString QClipboard::text () const

Returns the clipboard text, or a null string if the clipboard does not contain any text.

See also: setText().


Search the documentation, FAQ, qt-interest archive and more (uses www.troll.no):


This file is part of the Qt toolkit, copyright © 1995-99 Troll Tech, all rights reserved.


Copyright İ 1999 Troll TechTrademarks
Qt version 2.0.2