CopperSpice API
1.9.2
|
The QClipboard class provides access to the window system clipboard. More...
Public Types | |
enum | Mode |
Public Signals | |
void | changed (QClipboard::Mode mode) |
void | dataChanged () |
void | findBufferChanged () |
void | selectionChanged () |
Public Signals inherited from QObject | |
void | destroyed (QObject *obj=nullptr) |
void | objectNameChanged (const QString &objectName) |
Public Methods | |
void | clear (Mode mode=Clipboard) |
QImage | image (Mode mode=Clipboard) const |
const QMimeData * | mimeData (Mode mode=Clipboard) const |
bool | ownsClipboard () const |
bool | ownsFindBuffer () const |
bool | ownsSelection () const |
QPixmap | pixmap (Mode mode=Clipboard) const |
void | setImage (const QImage &image, Mode mode=Clipboard) |
void | setMimeData (QMimeData *data, Mode mode=Clipboard) |
void | setPixmap (const QPixmap &pixmap, Mode mode=Clipboard) |
void | setText (const QString &text, Mode mode=Clipboard) |
bool | supportsFindBuffer () const |
bool | supportsSelection () const |
QString | text (Mode mode=Clipboard) const |
QString | text (QString &subtype, Mode mode=Clipboard) const |
Public Methods inherited from QObject | |
QObject (QObject *parent=nullptr) | |
~QObject () | |
bool | blockSignals (bool block) |
const QList< QObject * > & | children () const |
bool | connect (const QObject *sender, const QString &signalMethod, const QString &location, const QString &slotMethod, Qt::ConnectionType type=Qt::AutoConnection) |
bool | connect (const QObject *sender, const QString &signalMethod, const QString &slotMethod, Qt::ConnectionType type=Qt::AutoConnection) |
bool | disconnect (const QObject *receiver, const QString &slotMethod=QString ()) const |
bool | disconnect (const QString &signalMethod, const QString &location, const QObject *receiver=nullptr, const QString &slotMethod=QString ()) const |
bool | disconnect (const QString &signalMethod=QString (), const QObject *receiver=nullptr, const QString &slotMethod=QString ()) const |
void | dumpObjectInfo () |
void | dumpObjectTree () |
QList< QString > | dynamicPropertyNames () const |
virtual bool | event (QEvent *event) |
virtual bool | eventFilter (QObject *watched, QEvent *event) |
template<typename T > | |
T | findChild (const QString &childName=QString ()) const |
template<class T > | |
QList< T > | findChildren (const QRegularExpression ®Exp, Qt::FindChildOptions options=Qt::FindChildrenRecursively) const |
template<class T > | |
QList< T > | findChildren (const QString &childName=QString (), Qt::FindChildOptions options=Qt::FindChildrenRecursively) const |
bool | inherits (const QString &className) const |
void | installEventFilter (QObject *filterObj) |
bool | isWidgetType () const |
bool | isWindowType () const |
void | killTimer (int id) |
const QMetaObject * | metaObject () const |
void | moveToThread (QThread *targetThread) |
QString | objectName () const |
QObject * | parent () const |
template<class T = QVariant> | |
T | property (const QString &name) const |
void | removeEventFilter (QObject *obj) |
void | setObjectName (const QString &name) |
void | setParent (QObject *parent) |
bool | setProperty (const QString &name, const QVariant &value) |
bool | signalsBlocked () const |
int | startTimer (int interval, Qt::TimerType timerType=Qt::CoarseTimer) |
QThread * | thread () const |
Friends | |
class | QApplication |
class | QPlatformClipboard |
Additional Inherited Members | |
Public Slots inherited from QObject | |
void | deleteLater () |
Static Public Methods inherited from QObject | |
static bool | connect (const QObject *sender, const QMetaMethod &signalMethod, const QObject *receiver, const QMetaMethod &slotMethod, Qt::ConnectionType type=Qt::AutoConnection) |
static bool | connect (const QObject *sender, const QString &signalMethod, const QObject *receiver, const QString &slotMethod, Qt::ConnectionType type=Qt::AutoConnection, const QString &location=QString ()) |
static bool | connect (const QObject *sender, const QString &signalMethod, const QString &location, const QObject *receiver, const QString &slotMethod, Qt::ConnectionType type=Qt::AutoConnection) |
template<class Sender , class SignalClass , class... SignalArgs, class Receiver , class SlotClass , class... SlotArgs, class SlotReturn > | |
static bool | connect (const Sender *sender, void (SignalClass::*signalMethod)(SignalArgs...), const Receiver *receiver, SlotReturn (SlotClass::*slotMethod)(SlotArgs...), Qt::ConnectionType type=Qt::AutoConnection) |
template<class Sender , class SignalClass , class... SignalArgs, class Receiver , class T > | |
static bool | connect (const Sender *sender, void (SignalClass::*signalMethod)(SignalArgs...), const Receiver *receiver, T slotLambda, Qt::ConnectionType type=Qt::AutoConnection) |
static bool | disconnect (const QObject *sender, const QMetaMethod &signalMethod, const QObject *receiver, const QMetaMethod &slotMethod) |
static bool | disconnect (const QObject *sender, const QString &signalMethod, const QObject *receiver, const QString &slotMethod) |
static bool | disconnect (const QObject *sender, const QString &signalMethod, const QString &location, const QObject *receiver, const QString &slotMethod) |
static bool | disconnect (const QObject *sender, std::nullptr_t, const QObject *receiver, std::nullptr_t) |
template<class Sender , class SignalClass , class... SignalArgs, class Receiver , class SlotClass , class... SlotArgs, class SlotReturn > | |
static bool | disconnect (const Sender *sender, void (SignalClass::*signalMethod)(SignalArgs...), const Receiver *receiver, SlotReturn (SlotClass::*slotMethod)(SlotArgs...)) |
template<class Sender , class SignalClass , class... SignalArgs, class Receiver > | |
static bool | disconnect (const Sender *sender, void (SignalClass::*signalMethod)(SignalArgs...), const Receiver *receiver, std::nullptr_t slotMethod=nullptr) |
template<class Sender , class SignalClass , class... SignalArgs, class Receiver , class T > | |
static bool | disconnect (const Sender *sender, void (SignalClass::*signalMethod)(SignalArgs...), const Receiver *receiver, T slotMethod) |
static QMetaObject & | staticMetaObject () |
static QString | tr (const char *text, const char *comment=nullptr, std::optional< int > numArg=std::optional< int >()) |
Protected Methods inherited from QObject | |
virtual void | childEvent (QChildEvent *event) |
virtual void | connectNotify (const QMetaMethod &signalMethod) const |
virtual void | customEvent (QEvent *event) |
virtual void | disconnectNotify (const QMetaMethod &signalMethod) const |
bool | isSignalConnected (const QMetaMethod &signalMethod) const |
int | receivers (const QString &signal) const |
QObject * | sender () const |
int | senderSignalIndex () const |
virtual void | timerEvent (QTimerEvent *event) |
Properties inherited from QObject | |
objectName | |
Related Functions inherited from QObject | |
T | qobject_cast (QObject *object) |
QObjectList | |
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().
QClipboard has several methods 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().
A typical example is shown below.
x-special/gnome-copied-files
MIME type with data beginning with the cut/copy action, a newline character, and the URL of the file. 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.
enum QClipboard::Mode |
This enum type is used to control which part of the system clipboard is used by QClipboard::mimeData(), QClipboard::setMimeData() and related functions.
Constant | Value | Description |
---|---|---|
QClipboard::Clipboard | 0 | Indicates data should be stored and retrieved from the global clipboard. |
QClipboard::Selection | 1 | Indicates that data should be stored and retrieved from the global mouse selection. Support for this enum is provided only on systems with a global mouse selection like X11. |
QClipboard::FindBuffer | 2 | Indicates the data should be stored and retrieved from the Find buffer. This mode is used for holding search strings on Mac OS X. |
|
signal |
This signal is emitted when the data for the given clipboard mode is changed.
void QClipboard::clear | ( | Mode | mode = Clipboard | ) |
Clear the clipboard contents.
The mode argument is used to control which part of the system clipboard is used. If mode is QClipboard::Clipboard, this function clears the global clipboard contents. If mode is QClipboard::Selection, this function clears the global mouse selection contents. If mode is QClipboard::FindBuffer, this function clears the search string buffer.
|
signal |
This signal is emitted when the clipboard data is changed.
Clipboard changes made by other applications will only be detected when the application is activated.
|
signal |
This signal is emitted when the find buffer is changed. This only applies to Mac OS X. Clipboard changes made by other applications will only be detected when the application is activated.
Returns the clipboard image, or returns a null image if the clipboard does not contain an image or if it contains an image in an unsupported image format.
The mode argument is used to control which part of the system clipboard is used. If mode is QClipboard::Clipboard, the image is retrieved from the global clipboard. If mode is QClipboard::Selection, the image is retrieved from the global mouse selection.
Returns a reference to a QMimeData representation of the current clipboard data.
The mode argument is used to control which part of the system clipboard is used. If mode is QClipboard::Clipboard, the data is retrieved from the global clipboard. If mode is QClipboard::Selection, the data is retrieved from the global mouse selection. If mode is QClipboard::FindBuffer, the data is retrieved from the search string buffer.
The text(), image(), and pixmap() functions are simpler wrappers for retrieving text, image, and pixmap data.
bool QClipboard::ownsClipboard | ( | ) | const |
Returns true if this clipboard object owns the clipboard data, otherwise returns false.
bool QClipboard::ownsFindBuffer | ( | ) | const |
Returns true if this clipboard object owns the find buffer data, otherwise returns false.
bool QClipboard::ownsSelection | ( | ) | const |
Returns true if this clipboard object owns the mouse selection data, otherwise returns false.
The mode is used to control which part of the system clipboard is used. If mode is Mode::Clipboard, the pixmap is retrieved from the global clipboard. If mode is Mode::Selection the pixmap is retrieved from the global mouse selection. Returns the clipboard pixmap or a null QPixMap if the clipboard does not contain a pixmap.
This method may need to convert the clipboard data and could lose information.For example, if the image is 24-bit and the display is 8-bit the result is converted to 8 bits.
|
signal |
This signal is emitted when the selection is changed. This only applies to windowing systems that support selections, like X11. Windows and Mac OS X do not support selections.
Copies the image into the clipboard.
The mode argument is used to control which part of the system clipboard is used. If mode is QClipboard::Clipboard, the image is stored in the global clipboard. If mode is QClipboard::Selection the data is stored in the global mouse selection.
Calling this method is equivalent to the following example.
Sets the clipboard data to data. Ownership of the data is transferred to the clipboard. If you want to remove the data either call clear() or call setMimeData() again with new data.
The mode argument is used to control which part of the system clipboard is used. If mode is QClipboard::Clipboard, the data is stored in the global clipboard. If mode is QClipboard::Selection, the data is stored in the global mouse selection. If mode is QClipboard::FindBuffer, the data is stored in the search string buffer.
The setText(), setImage() and setPixmap() functions are simpler wrappers for setting text, image and pixmap data respectively.
Copies pixmap into the clipboard. This is slower than calling setImage() because it needs to convert the QPixmap to a QImage first.
The mode argument is used to control which part of the system clipboard is used. If mode is QClipboard::Clipboard, the pixmap is stored in the global clipboard. If mode is QClipboard::Selection, the pixmap is stored in the global mouse selection.
Copies text into the clipboard as plain text. The mode argument is used to control which part of the system clipboard is used. If mode is QClipboard::Clipboard, the text is stored in the global clipboard. If mode is QClipboard::Selection, the text is stored in the global mouse selection. If mode is QClipboard::FindBuffer, the text is stored in the search string buffer.
bool QClipboard::supportsFindBuffer | ( | ) | const |
Returns true if the clipboard supports a separate search buffer, otherwise returns false.
bool QClipboard::supportsSelection | ( | ) | const |
Returns true if the clipboard supports mouse selection, otherwise returns false.
Returns the clipboard text as plain text, or an empty string if the clipboard does not contain any text.
The mode argument is used to control which part of the system clipboard is used. If mode is QClipboard::Clipboard, the text is retrieved from the global clipboard. If mode is QClipboard::Selection, the text is retrieved from the global mouse selection. If mode is QClipboard::FindBuffer, the text is retrieved from the search string buffer.
Returns the contents of the clipboard for the given subtype or an empty string if the clipboard does not contain text of the request subtype. Common values for subtype are "plain" or "html". If this specified subtype is empty then text for any subtype will be returned. In this case the subtype parameter will be updated to reflect the subtype which was used.
The mode argument is used to control which part of the system clipboard is used. If mode is QClipboard::Clipboard, the text is retrieved from the global clipboard. If mode is QClipboard::Selection the text is retrieved from the global mouse selection.
Calling this method repeatedly may be slow. In such cases use the dataChanged()
signal.