![]()  | 
  
     v1.3.0.0
    
   | 
 
The Clipboard class offers a simple mechanism to copy and paste data between applications.
Clipboard features are implemented as a module named clipboard. Use an import statement (from another module) or require() function call (from any code) to import desired features.
Or using require(): 
Clipboard data can potentially contain multiple types of data, identified by a MIME (or "media") type. For example copying text from a Web page may put it on the clipboard in both plain-text and HTML formats ("text/plain" and "text/html" MIME types, respectively).
The text(), setText(), data() and setData() function versions with no parameters operate with "text/plain" and "application/octet-stream" default MIME types (as further explained in their documentation). Alternatively, the more explicit function overloads can be used which allow specifying a MIME type.
On MacOS and Linux/X11 systems there are two other "clipboard modes" available besides the primary shared clipbaord. 
On X11 this can work with whatever text is currently selected in a focused application (Clipboard.Selection mode). 
On MacOS there is a special "search buffer" which can be shared between applications (Clipboard.SearchBuffer mode). 
Most of the functions in this class accept an optional mode parameter which sets which clipboard to use. By default the main clipboard is used, and on Windows this is the only clipboard mode available. 
See supportsSelection, supportsFindBuffer, and Mode enumeration docs for more details.
Public Types | |
| enum class | Mode | 
Properties | |
| bool | supportsFindBuffer = QGuiApplication::clipboard()->supportsFindBuffer() | 
| bool | supportsSelection = QGuiApplication::clipboard()->supportsSelection() | 
Public Member Functions | |
| bool | dataAvailable (int mode=Mode.Clipboard) | 
| bool | textAvailable (int mode=Mode.Clipboard) | 
| String | text (int mode=Mode.Clipboard) | 
| String | text (String subType, int mode=Mode.Clipboard) | 
| String | setText (String text, int mode=Mode.Clipboard) | 
| String | setText (String subType, String text, int mode=Mode.Clipboard) | 
| ArrayBuffer | data (int mode=Mode.Clipboard) | 
| ArrayBuffer | data (String mimeType, int mode=Mode.Clipboard) | 
| void | setData (ArrayBuffer data, int mode=Mode.Clipboard) | 
| void | setData (String mimeType, ArrayBuffer data, int mode=Mode.Clipboard) | 
| void | clear (int mode=Mode.Clipboard) | 
| bool | hasMimeType (String mimeType, int mode=Mode.Clipboard) | 
| bool | hasMediaType (String mediaType, int mode=Mode.Clipboard) | 
| Array< String > | mimeTypes (String mimeType, int mode=Mode.Clipboard) | 
Events  | |
See Event Handling for details about connecting handlers to events. Note** that since   | |
| void | clipboardChanged () | 
| void | findBufferChanged () | 
| void | selectionChanged () | 
      
  | 
  strong | 
This enumeration is used in the mode argument of several methods and controls which part of the system clipboard is used. 
With Clipboard mode (the deafult for all methods), the data is stored/retrieved with the global clipboard. 
If mode is Selection, the data is stored/retrieved with the global mouse selection (requires a supporting system, eg. X11). 
If mode is FindBuffer, the data is stored/retrieved with the search string buffer (eg. on MacOS). 
      
  | 
  readwrite | 
This property value is true if the system clipboard supports a separate search buffer, or false otherwise. This is only supported on MacOS and possibly some Android systems. 
      
  | 
  readwrite | 
This property value is true if the system clipboard supports mouse selection, or false otherwise. Mouse selection is generally only supported on X11-based systems (Linux, BSD, etc). 
| void clipboardChanged | ( | ) | 
| void findBufferChanged | ( | ) | 
This event is raised whenever the contents of the Find text change on MacOS. Use text(), data(), etc methods with mode argument set to Clipboard.FindBuffer to get the current value after receiving this event. 
This event has a corresponding onfindBufferChanged property to which a single event handler may be assigned. 
| void selectionChanged | ( | ) | 
This event is raised whenever the contents of the system selection change. Use text(), data(), etc, methods with mode argument set to Clipboard.Selection to get the current value after receiving this event. 
This event has a corresponding onselectionChanged property to which a single event handler may be assigned. 
| bool dataAvailable | ( | int | mode = Mode.Clipboard | ) | 
Returns true if the current system clipboard contains any type of data at all (ie. is not empty), or false otherwise (if the clipboard is empty). 
 The opitonal mode argument is used to control which part of the system clipboard is used. 
| bool textAvailable | ( | int | mode = Mode.Clipboard | ) | 
Returns true if the current system clipboard contains any type of string data, or false otherwise. String data would be any type with a "text" primary MIME type, eg "text/plain", "text/html", "text/csv", etc. 
 The opitonal mode argument is used to control which part of the system clipboard is used. 
| String text | ( | int | mode = Mode.Clipboard | ) | 
Returns the current system clipboard value as a plain text String type (ASCII/UTF8/UTF16). If the clipboard contains multipe value data types it will return:
if no text types are found, or the clipboard is entirely empty, an empty string is returned.
To specify an explicit text type, use the text() function version which takes that option as the first parameter (see below). 
 The opitonal mode argument is used to control which part of the system clipboard is used. 
| String text | ( | String | subType, | 
| int | mode = Mode.Clipboard  | 
        ||
| ) | 
Returns the clipboard text with MIME subtype subType, or an empty string if the clipboard does not contain any text of the given subtype. The subtype is just the part after "text/" of a MIME type, eg. "plain", "html", "csv", etc. It can optionally include peropery(ies), for example a character encoding like "plain;charset=utf-8". The name search is case-insensitive. 
 The opitonal mode argument is used to control which part of the system clipboard is used. 
| String setText | ( | String | text, | 
| int | mode = Mode.Clipboard  | 
        ||
| ) | 
| String setText | ( | String | subType, | 
| String | text, | ||
| int | mode = Mode.Clipboard  | 
        ||
| ) | 
Sets the clipboard text with MIME subtype subType to text. The subtype is just the part after "text/" of a MIME type, eg. "plain", "html", "csv", etc. 
 The opitonal mode argument is used to control which part of the system clipboard is used. 
| ArrayBuffer data | ( | int | mode = Mode.Clipboard | ) | 
Returns the current system clipboard value as raw bytes. 
When reading the value: 
ArrayBuffer is returned;To specify a MIME type, use data() function version which takes that as the first parameter. 
 The opitonal mode argument is used to control which part of the system clipboard is used. 
| ArrayBuffer data | ( | String | mimeType, | 
| int | mode = Mode.Clipboard  | 
        ||
| ) | 
Get the raw byte data associated with MIME type mimeType from the current system clipboard. If the clipboard didn't have the specified MIME type, then an empty ArrayBuffer is returned. 
 The opitonal mode argument is used to control which part of the system clipboard is used. 
| void setData | ( | ArrayBuffer | data, | 
| int | mode = Mode.Clipboard  | 
        ||
| ) | 
Sets the current system clipboard value as raw bytes. It is written to the clipboard as "application/octet-stream" MIME type. 
 The opitonal mode argument is used to control which part of the system clipboard is used. 
| void setData | ( | String | mimeType, | 
| ArrayBuffer | data, | ||
| int | mode = Mode.Clipboard  | 
        ||
| ) | 
Set raw byte data with MIME type mimeType to data on the current system clipboard. The opitonal mode argument is used to control which part of the system clipboard is used. 
| void clear | ( | int | mode = Mode.Clipboard | ) | 
Clears the system clipboard of all values. 
 The opitonal mode argument is used to control which part of the system clipboard is used. 
| bool hasMimeType | ( | String | mimeType, | 
| int | mode = Mode.Clipboard  | 
        ||
| ) | 
Checks if the clipboard contains data with full MIME type mimeType and returns true or false. The full MIME type is a combination of type, subtype, and possibly one or more parameters/values. For example: "text/plain" or "text/plain;charset=UTF-8" 
 The opitonal mode argument is used to control which part of the system clipboard is used. 
| bool hasMediaType | ( | String | mediaType, | 
| int | mode = Mode.Clipboard  | 
        ||
| ) | 
Checks if the clipboard contains data with base MIME type mediaType and returns true or false. The "media type" is the first part of a full MIME type before the slash (/), w/out a subtype or parameters. For example: "text", "application", "image", etc. 
 The opitonal mode argument is used to control which part of the system clipboard is used. 
| Array< String > mimeTypes | ( | String | mimeType, | 
| int | mode = Mode.Clipboard  | 
        ||
| ) | 
Returns an array of formats contained in the clipboard, if any. This is a list of MIME types for which the object can return suitable data. The formats in the list are in a priority order. 
 The opitonal mode argument is used to control which part of the system clipboard is used.