Ubuntu.Components.Clipboard

This is a singleton type providing access to the system clipboard. More...

Import Statement: import Ubuntu.Components 1.3

Properties

Signals

Methods

Detailed Description

Clipboard data can be retrieved through data property, which returns an object of MimeData type. The actual content of the clipboard can be accessed through this object. Data can be pushed to the clipboard using push() function.

The clipboard data cannot be modified through the type returned by the data property, for this a new instance of MimeData type must be used. This instance can be either a standalone MimeDala component or an object created using newData() function. Remember that standalone MimeData types duplicate the clipboard data which may cause extensive memory use.

Examples of use:

1. Using standard MimeType component - the following example copies the selected text from the text area into the clipboard pushing also a color

Item {
TextArea {
id: editor
}
MimeData {
id: mimeData
color: "green"
text: editor.text
}
Button {
text: "Copy"
onClicked: Clipboard.push(mimeData)
}
}

2. Pushing data straight to clipboard

Item {
TextArea {
id: editor
}
Button {
text: "Copy"
onClicked: {
Clipboard.push(editor.text);
Clipboard.push(["application/x-color", "green"]);
}
}
}

3. Pushing data using MimeData object

Item {
TextArea {
id: editor
}
Button {
text: "Copy"
onClicked: {
var mimeData = Clipboard.newData();
mimeData.text = editor.text;
mimeData.color = "green";
Clipboard.push(mimeData);
}
}
}

Property Documentation

data : MimeData

Provides access to the Clipboard's current data.


Signal Documentation

dataChanged()

The signal is triggered when clipboard content gets changed.


Method Documentation

clear()

The function clears the clipboard content.


MimeData newData()

The function returns a new MimeData object that can be used in Java script code to push pultiple MIME types at the same time.


push(http://doc.qt.io/qt-5/qml-var.html">var data)

The function copies data provided as parameter to the clipboard. The parameter can be a MimeData instance or object created using newData() beside the ones listed at MimeData::data.

When MimeData instance or object is given, the entire object content will be pushed to the clipboard.