~oif-team/ubuntu/natty/qt4-x11/xi2.1

« back to all changes in this revision

Viewing changes to doc/html/qclipboard.html

  • Committer: Bazaar Package Importer
  • Author(s): Adam Conrad
  • Date: 2005-08-24 04:09:09 UTC
  • Revision ID: james.westby@ubuntu.com-20050824040909-xmxe9jfr4a0w5671
Tags: upstream-4.0.0
ImportĀ upstreamĀ versionĀ 4.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<?xml version="1.0" encoding="iso-8859-1"?>
 
2
<!DOCTYPE html
 
3
    PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd">
 
4
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
 
5
<!-- /tmp/qt-4.0.0-espenr-1119621036935/qt-x11-opensource-desktop-4.0.0/src/gui/kernel/qclipboard.cpp -->
 
6
<head>
 
7
    <title>Qt 4.0: QClipboard Class Reference</title>
 
8
    <style>h3.fn,span.fn { margin-left: 1cm; text-indent: -1cm; }
 
9
a:link { color: #004faf; text-decoration: none }
 
10
a:visited { color: #672967; text-decoration: none }
 
11
td.postheader { font-family: sans-serif }
 
12
tr.address { font-family: sans-serif }
 
13
body { background: #ffffff; color: black; }</style>
 
14
</head>
 
15
<body>
 
16
<table border="0" cellpadding="0" cellspacing="0" width="100%">
 
17
<tr>
 
18
<td align="left" valign="top" width="32"><img src="images/qt-logo.png" align="left" width="32" height="32" border="0" /></td>
 
19
<td width="1">&nbsp;&nbsp;</td><td class="postheader" valign="center"><a href="index.html"><font color="#004faf">Home</font></a>&nbsp;&middot; <a href="classes.html"><font color="#004faf">All&nbsp;Classes</font></a>&nbsp;&middot; <a href="mainclasses.html"><font color="#004faf">Main&nbsp;Classes</font></a>&nbsp;&middot; <a href="annotated.html"><font color="#004faf">Annotated</font></a>&nbsp;&middot; <a href="groups.html"><font color="#004faf">Grouped&nbsp;Classes</font></a>&nbsp;&middot; <a href="functions.html"><font color="#004faf">Functions</font></a></td>
 
20
<td align="right" valign="top" width="230"><img src="images/trolltech-logo.png" align="right" width="203" height="32" border="0" /></td></tr></table><h1 align="center">QClipboard Class Reference</h1>
 
21
<p>The QClipboard class provides access to the window system clipboard. <a href="#details">More...</a></p>
 
22
<pre>#include &lt;QClipboard&gt;</pre><p>Part of the <a href="qtgui.html">QtGui</a> module.</p>
 
23
<p>Inherits <a href="qobject.html">QObject</a>.</p>
 
24
<ul>
 
25
<li><a href="qclipboard-members.html">List of all members, including inherited members</a></li>
 
26
<li><a href="qclipboard-qt3.html">Qt 3 support members</a></li>
 
27
</ul>
 
28
<a name="public-types"></a>
 
29
<h3>Public Types</h3>
 
30
<ul>
 
31
<li><div class="fn"/>enum <b><a href="qclipboard.html#Mode-enum">Mode</a></b> { Clipboard, Selection }</li>
 
32
</ul>
 
33
<a name="public-functions"></a>
 
34
<h3>Public Functions</h3>
 
35
<ul>
 
36
<li><div class="fn"/>void <b><a href="qclipboard.html#clear">clear</a></b> ( Mode <i>mode</i> = Clipboard )</li>
 
37
<li><div class="fn"/>QImage <b><a href="qclipboard.html#image">image</a></b> ( Mode <i>mode</i> = Clipboard ) const</li>
 
38
<li><div class="fn"/>const QMimeData * <b><a href="qclipboard.html#mimeData">mimeData</a></b> ( Mode <i>mode</i> = Clipboard ) const</li>
 
39
<li><div class="fn"/>bool <b><a href="qclipboard.html#ownsClipboard">ownsClipboard</a></b> () const</li>
 
40
<li><div class="fn"/>bool <b><a href="qclipboard.html#ownsSelection">ownsSelection</a></b> () const</li>
 
41
<li><div class="fn"/>QPixmap <b><a href="qclipboard.html#pixmap">pixmap</a></b> ( Mode <i>mode</i> = Clipboard ) const</li>
 
42
<li><div class="fn"/>void <b><a href="qclipboard.html#setImage">setImage</a></b> ( const QImage &amp; <i>image</i>, Mode <i>mode</i> = Clipboard )</li>
 
43
<li><div class="fn"/>void <b><a href="qclipboard.html#setMimeData">setMimeData</a></b> ( QMimeData * <i>src</i>, Mode <i>mode</i> = Clipboard )</li>
 
44
<li><div class="fn"/>void <b><a href="qclipboard.html#setPixmap">setPixmap</a></b> ( const QPixmap &amp; <i>pixmap</i>, Mode <i>mode</i> = Clipboard )</li>
 
45
<li><div class="fn"/>void <b><a href="qclipboard.html#setText">setText</a></b> ( const QString &amp; <i>text</i>, Mode <i>mode</i> = Clipboard )</li>
 
46
<li><div class="fn"/>bool <b><a href="qclipboard.html#supportsSelection">supportsSelection</a></b> () const</li>
 
47
<li><div class="fn"/>QString <b><a href="qclipboard.html#text">text</a></b> ( Mode <i>mode</i> = Clipboard ) const</li>
 
48
<li><div class="fn"/>QString <b><a href="qclipboard.html#text-2">text</a></b> ( QString &amp; <i>subtype</i>, Mode <i>mode</i> = Clipboard ) const</li>
 
49
</ul>
 
50
<ul>
 
51
<li><div class="fn"/>28 public functions inherited from <a href="qobject.html#public-functions">QObject</a></li>
 
52
</ul>
 
53
<a name="signals"></a>
 
54
<h3>Signals</h3>
 
55
<ul>
 
56
<li><div class="fn"/>void <b><a href="qclipboard.html#dataChanged">dataChanged</a></b> ()</li>
 
57
<li><div class="fn"/>void <b><a href="qclipboard.html#selectionChanged">selectionChanged</a></b> ()</li>
 
58
</ul>
 
59
<ul>
 
60
<li><div class="fn"/>1 signal inherited from <a href="qobject.html#signals">QObject</a></li>
 
61
</ul>
 
62
<h3>Additional Inherited Members</h3>
 
63
<ul>
 
64
<li><div class="fn"/>1 property inherited from <a href="qobject.html#properties">QObject</a></li>
 
65
<li><div class="fn"/>1 public slot inherited from <a href="qobject.html#public-slots">QObject</a></li>
 
66
<li><div class="fn"/>4 static public members inherited from <a href="qobject.html#static-public-members">QObject</a></li>
 
67
<li><div class="fn"/>7 protected functions inherited from <a href="qobject.html#protected-functions">QObject</a></li>
 
68
</ul>
 
69
<a name="details"></a>
 
70
<hr />
 
71
<h2>Detailed Description</h2>
 
72
<p>The QClipboard class provides access to the window system clipboard.</p>
 
73
<p>The clipboard offers a simple mechanism to copy and paste data between applications.</p>
 
74
<p>QClipboard supports the same data types that <a href="qdrag.html">QDrag</a> does, and uses similar mechanisms. For advanced clipboard usage read <a href="dnd.html">Drag and Drop</a>.</p>
 
75
<p>There is a single QClipboard object in an application, accessible as <a href="qapplication.html#clipboard">QApplication::clipboard</a>().</p>
 
76
<p>Example:</p>
 
77
<pre>&nbsp;   QClipboard *clipboard = QApplication::clipboard();
 
78
    QString originalText = clipboard-&gt;text();
 
79
    ...
 
80
    clipboard-&gt;setText(newText);</pre>
 
81
<p>QClipboard features some convenience functions to access common data types: <a href="qclipboard.html#setText">setText</a>() allows the exchange of Unicode text and <a href="qclipboard.html#setPixmap">setPixmap</a>() and <a href="qclipboard.html#setImage">setImage</a>() allows the exchange of QPixmaps and QImages between applications. The <a href="qclipboard.html#setMimeData">setMimeData</a>() function is the ultimate in flexibility: it allows you to add any <a href="qmimedata.html">QMimeData</a> into the clipboard. There are corresponding getters for each of these, e.g. <a href="qclipboard.html#text">text</a>(), <a href="qclipboard.html#image">image</a>() and <a href="qclipboard.html#pixmap">pixmap</a>(). You can clear the clipboard by calling <a href="qclipboard.html#clear">clear</a>().</p>
 
82
<a name="notes-for-x11-users"></a>
 
83
<h3>Notes for X11 Users</h3>
 
84
<ul>
 
85
<li>The <a href="winsystem.html#x11">X11</a> Window System has the concept of a separate selection and clipboard. When text is selected, it is immediately available as the global mouse selection. The global mouse selection may later be copied to the clipboard. By convention, the middle mouse button is used to paste the global mouse selection.</li>
 
86
<li><a href="winsystem.html#x11">X11</a> also has the concept of ownership; if you change the selection within a window, <a href="winsystem.html#x11">X11</a> will only notify the owner and the previous owner of the change, i.e. it will not notify all applications that the selection or clipboard data changed.</li>
 
87
<li>Lastly, the <a href="winsystem.html#x11">X11</a> clipboard is event driven, i.e. the clipboard will not function properly if the event loop is not running. Similarly, it is recommended that the contents of the clipboard are stored or retrieved in direct response to user-input events, e.g. mouse button or key presses and releases. You should not store or retrieve the clipboard contents in response to timer or non-user-input events.</li>
 
88
</ul>
 
89
<a name="notes-for-windows-and-mac-os-x-users"></a>
 
90
<h3>Notes for Windows and Mac OS X Users</h3>
 
91
<ul>
 
92
<li>Windows and Mac OS X do not support the global mouse selection; they only supports the global clipboard, i.e. they only adds text to the clipboard when an explicit copy or cut is made.</li>
 
93
<li>Windows and Mac OS X does not have the concept of ownership; the clipboard is a fully global resource so all applications are notified of changes.</li>
 
94
</ul>
 
95
<p>See also <a href="qapplication.html">QApplication</a>.</p>
 
96
<hr />
 
97
<h2>Member Type Documentation</h2>
 
98
<h3 class="fn"><a name="Mode-enum"></a>enum QClipboard::Mode</h3>
 
99
<a name="clipboard-mode"></a><p>This enum type is used to control which part of the system clipboard is used by <a href="qclipboard-qt3.html#data">QClipboard::data</a>(), <a href="qclipboard-qt3.html#setData">QClipboard::setData</a>() and related functions.</p>
 
100
<table border="1" cellpadding="2" cellspacing="1" width="100%">
 
101
<tr><th width="25%">Constant</th><th width="15%">Value</th><th width="60%">Description</th></tr>
 
102
<tr><td valign="top"><tt>QClipboard::Clipboard</tt></td><td align="center" valign="top"><tt>0</tt></td><td valign="top">indicates that data should be stored and retrieved from the global clipboard.</td></tr>
 
103
<tr><td valign="top"><tt>QClipboard::Selection</tt></td><td align="center" valign="top"><tt>1</tt></td><td valign="top">indicates that data should be stored and retrieved from the global mouse selection.</td></tr>
 
104
</table>
 
105
<p><i>Note</i>: Support for <tt>Selection</tt> is provided only on systems with a global mouse selection (e.g. <a href="winsystem.html#x11">X11</a>).</p>
 
106
<p>See also <a href="qclipboard.html#supportsSelection">QClipboard::supportsSelection</a>().</p>
 
107
<hr />
 
108
<h2>Member Function Documentation</h2>
 
109
<h3 class="fn"><a name="clear"></a>void QClipboard::clear ( <a href="qclipboard.html#Mode-enum">Mode</a> <i>mode</i> = Clipboard )</h3>
 
110
<p>Clear the clipboard contents.</p>
 
111
<p>The <i>mode</i> argument is used to control which part of the system clipboard is used. If <i>mode</i> is <a href="qclipboard.html#Mode-enum">QClipboard::Clipboard</a>, this function clears the the global clipboard contents. If <i>mode</i> is <a href="qclipboard.html#Mode-enum">QClipboard::Selection</a>, this function clears the global mouse selection contents.</p>
 
112
<p>See also <a href="qclipboard.html#Mode-enum">QClipboard::Mode</a> and <a href="qclipboard.html#supportsSelection">supportsSelection</a>().</p>
 
113
<h3 class="fn"><a name="dataChanged"></a>void QClipboard::dataChanged ()&nbsp;&nbsp;<tt> [signal]</tt></h3>
 
114
<p>This signal is emitted when the clipboard data is changed.</p>
 
115
<h3 class="fn"><a name="image"></a><a href="qimage.html">QImage</a> QClipboard::image ( <a href="qclipboard.html#Mode-enum">Mode</a> <i>mode</i> = Clipboard ) const</h3>
 
116
<p>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.</p>
 
117
<p>The <i>mode</i> argument is used to control which part of the system clipboard is used. If <i>mode</i> is <a href="qclipboard.html#Mode-enum">QClipboard::Clipboard</a>, the image is retrieved from the global clipboard. If <i>mode</i> is <a href="qclipboard.html#Mode-enum">QClipboard::Selection</a>, the image is retrieved from the global mouse selection.</p>
 
118
<p>See also <a href="qclipboard.html#setImage">setImage</a>(), <a href="qclipboard.html#pixmap">pixmap</a>(), <a href="qclipboard-qt3.html#data">data</a>(), and <a href="qimage.html#isNull">QImage::isNull</a>().</p>
 
119
<h3 class="fn"><a name="mimeData"></a>const <a href="qmimedata.html">QMimeData</a> * QClipboard::mimeData ( <a href="qclipboard.html#Mode-enum">Mode</a> <i>mode</i> = Clipboard ) const</h3>
 
120
<p>Returns a reference to a <a href="qmimedata.html">QMimeData</a> representation of the current clipboard data.</p>
 
121
<p>The <i>mode</i> argument is used to control which part of the system clipboard is used. If <i>mode</i> is <a href="qclipboard.html#Mode-enum">QClipboard::Clipboard</a>, the data is retrieved from the global clipboard. If <i>mode</i> is <a href="qclipboard.html#Mode-enum">QClipboard::Selection</a>, the data is retrieved from the global mouse selection.</p>
 
122
<p>The <a href="qclipboard.html#text">text</a>(), <a href="qclipboard.html#image">image</a>(), and <a href="qclipboard.html#pixmap">pixmap</a>() functions are simpler wrappers for retrieving text, image, and pixmap data.</p>
 
123
<p>See also <a href="qclipboard.html#setMimeData">setMimeData</a>().</p>
 
124
<h3 class="fn"><a name="ownsClipboard"></a>bool QClipboard::ownsClipboard () const</h3>
 
125
<p>Returns true if this clipboard object owns the clipboard data; otherwise returns false.</p>
 
126
<h3 class="fn"><a name="ownsSelection"></a>bool QClipboard::ownsSelection () const</h3>
 
127
<p>Returns true if this clipboard object owns the mouse selection data; otherwise returns false.</p>
 
128
<h3 class="fn"><a name="pixmap"></a><a href="qpixmap.html">QPixmap</a> QClipboard::pixmap ( <a href="qclipboard.html#Mode-enum">Mode</a> <i>mode</i> = Clipboard ) const</h3>
 
129
<p>Returns the clipboard pixmap, or null if the clipboard does not contain a pixmap. Note that this can lose information. For example, if the image is 24-bit and the display is 8-bit, the result is converted to 8 bits, and if the image has an alpha channel, the result just has a mask.</p>
 
130
<p>The <i>mode</i> argument is used to control which part of the system clipboard is used. If <i>mode</i> is <a href="qclipboard.html#Mode-enum">QClipboard::Clipboard</a>, the pixmap is retrieved from the global clipboard. If <i>mode</i> is <a href="qclipboard.html#Mode-enum">QClipboard::Selection</a>, the pixmap is retrieved from the global mouse selection.</p>
 
131
<p>See also <a href="qclipboard.html#setPixmap">setPixmap</a>(), <a href="qclipboard.html#image">image</a>(), <a href="qclipboard-qt3.html#data">data</a>(), and <a href="qpixmap-qt3.html#convertFromImage">QPixmap::convertFromImage</a>().</p>
 
132
<h3 class="fn"><a name="selectionChanged"></a>void QClipboard::selectionChanged ()&nbsp;&nbsp;<tt> [signal]</tt></h3>
 
133
<p>This signal is emitted when the selection is changed. This only applies to windowing systems that support selections, e.g. <a href="winsystem.html#x11">X11</a>. Windows doesn't support selections.</p>
 
134
<h3 class="fn"><a name="setImage"></a>void QClipboard::setImage ( const <a href="qimage.html">QImage</a> &amp; <i>image</i>, <a href="qclipboard.html#Mode-enum">Mode</a> <i>mode</i> = Clipboard )</h3>
 
135
<p>Copies the <i>image</i> into the clipboard.</p>
 
136
<p>The <i>mode</i> argument is used to control which part of the system clipboard is used. If <i>mode</i> is <a href="qclipboard.html#Mode-enum">QClipboard::Clipboard</a>, the image is stored in the global clipboard. If <i>mode</i> is <a href="qclipboard.html#Mode-enum">QClipboard::Selection</a>, the data is stored in the global mouse selection.</p>
 
137
<p>This is shorthand for:</p>
 
138
<pre>&nbsp;   QMimeData *data = new QMimeData;
 
139
    data-&gt;setPixmap(image);
 
140
    clipboard-&gt;setMimeData(data, mode);</pre>
 
141
<p>See also <a href="qclipboard.html#image">image</a>(), <a href="qclipboard.html#setPixmap">setPixmap</a>(), and <a href="qclipboard-qt3.html#setData">setData</a>().</p>
 
142
<h3 class="fn"><a name="setMimeData"></a>void QClipboard::setMimeData ( <a href="qmimedata.html">QMimeData</a> * <i>src</i>, <a href="qclipboard.html#Mode-enum">Mode</a> <i>mode</i> = Clipboard )</h3>
 
143
<p>Sets the clipboard data to <i>src</i>. Ownership of the data is transferred to the clipboard. If you want to remove the data either call <a href="qclipboard.html#clear">clear</a>() or call <a href="qclipboard-qt3.html#setData">setData</a>() again with new data.</p>
 
144
<p>The <i>mode</i> argument is used to control which part of the system clipboard is used. If <i>mode</i> is <a href="qclipboard.html#Mode-enum">QClipboard::Clipboard</a>, the data is retrieved from the global clipboard. If <i>mode</i> is <a href="qclipboard.html#Mode-enum">QClipboard::Selection</a>, the data is retrieved from the global mouse selection.</p>
 
145
<p>The <a href="qclipboard.html#setText">setText</a>(), <a href="qclipboard.html#setImage">setImage</a>() and <a href="qclipboard.html#setPixmap">setPixmap</a>() functions are simpler wrappers for setting text, image and pixmap data respectively.</p>
 
146
<p>See also <a href="qclipboard-qt3.html#data">data</a>().</p>
 
147
<h3 class="fn"><a name="setPixmap"></a>void QClipboard::setPixmap ( const <a href="qpixmap.html">QPixmap</a> &amp; <i>pixmap</i>, <a href="qclipboard.html#Mode-enum">Mode</a> <i>mode</i> = Clipboard )</h3>
 
148
<p>Copies <i>pixmap</i> into the clipboard. Note that this is slower than <a href="qclipboard.html#setImage">setImage</a>() because it needs to convert the <a href="qpixmap.html">QPixmap</a> to a <a href="qimage.html">QImage</a> first.</p>
 
149
<p>The <i>mode</i> argument is used to control which part of the system clipboard is used. If <i>mode</i> is <a href="qclipboard.html#Mode-enum">QClipboard::Clipboard</a>, the pixmap is stored in the global clipboard. If <i>mode</i> is <a href="qclipboard.html#Mode-enum">QClipboard::Selection</a>, the pixmap is stored in the global mouse selection.</p>
 
150
<p>See also <a href="qclipboard.html#pixmap">pixmap</a>(), <a href="qclipboard.html#setImage">setImage</a>(), and <a href="qclipboard-qt3.html#setData">setData</a>().</p>
 
151
<h3 class="fn"><a name="setText"></a>void QClipboard::setText ( const <a href="qstring.html">QString</a> &amp; <i>text</i>, <a href="qclipboard.html#Mode-enum">Mode</a> <i>mode</i> = Clipboard )</h3>
 
152
<p>Copies <i>text</i> into the clipboard as plain text.</p>
 
153
<p>The <i>mode</i> argument is used to control which part of the system clipboard is used. If <i>mode</i> is <a href="qclipboard.html#Mode-enum">QClipboard::Clipboard</a>, the text is stored in the global clipboard. If <i>mode</i> is <a href="qclipboard.html#Mode-enum">QClipboard::Selection</a>, the text is stored in the global mouse selection.</p>
 
154
<p>See also <a href="qclipboard.html#text">text</a>() and <a href="qclipboard-qt3.html#setData">setData</a>().</p>
 
155
<h3 class="fn"><a name="supportsSelection"></a>bool QClipboard::supportsSelection () const</h3>
 
156
<p>Returns true if the clipboard supports mouse selection; otherwise returns false.</p>
 
157
<h3 class="fn"><a name="text"></a><a href="qstring.html">QString</a> QClipboard::text ( <a href="qclipboard.html#Mode-enum">Mode</a> <i>mode</i> = Clipboard ) const</h3>
 
158
<p>Returns the clipboard text as plain text, or an empty string if the clipboard does not contain any text.</p>
 
159
<p>The <i>mode</i> argument is used to control which part of the system clipboard is used. If <i>mode</i> is <a href="qclipboard.html#Mode-enum">QClipboard::Clipboard</a>, the text is retrieved from the global clipboard. If <i>mode</i> is <a href="qclipboard.html#Mode-enum">QClipboard::Selection</a>, the text is retrieved from the global mouse selection.</p>
 
160
<p>See also <a href="qclipboard.html#setText">setText</a>() and <a href="qclipboard-qt3.html#data">data</a>().</p>
 
161
<h3 class="fn"><a name="text-2"></a><a href="qstring.html">QString</a> QClipboard::text ( <a href="qstring.html">QString</a> &amp; <i>subtype</i>, <a href="qclipboard.html#Mode-enum">Mode</a> <i>mode</i> = Clipboard ) const</h3>
 
162
<p>This is an overloaded member function, provided for convenience. It behaves essentially like the above function.</p>
 
163
<p>Returns the clipboard text in subtype <i>subtype</i>, or an empty string if the clipboard does not contain any text. If <i>subtype</i> is null, any subtype is acceptable, and <i>subtype</i> is set to the chosen subtype.</p>
 
164
<p>The <i>mode</i> argument is used to control which part of the system clipboard is used. If <i>mode</i> is <a href="qclipboard.html#Mode-enum">QClipboard::Clipboard</a>, the text is retrieved from the global clipboard. If <i>mode</i> is <a href="qclipboard.html#Mode-enum">QClipboard::Selection</a>, the text is retrieved from the global mouse selection.</p>
 
165
<p>Common values for <i>subtype</i> are &quot;plain&quot; and &quot;html&quot;.</p>
 
166
<p>See also <a href="qclipboard.html#setText">setText</a>() and <a href="qclipboard-qt3.html#data">data</a>().</p>
 
167
<p /><address><hr /><div align="center">
 
168
<table width="100%" cellspacing="0" border="0"><tr class="address">
 
169
<td width="30%">Copyright &copy; 2005 <a href="trolltech.html">Trolltech</a></td>
 
170
<td width="40%" align="center"><a href="trademarks.html">Trademarks</a></td>
 
171
<td width="30%" align="right"><div align="right">Qt 4.0.0</div></td>
 
172
</tr></table></div></address></body>
 
173
</html>