📄 qclipboard.3qt
字号:
'\" t.TH QClipboard 3qt "11 October 2001" "Trolltech AS" \" -*- nroff -*-.\" Copyright 1992-2001 Trolltech AS. All rights reserved. See the.\" license file included in the distribution for a complete license.\" statement..\".ad l.nh.SH NAMEQClipboard \- Access to the window system clipboard.PP\fC#include <qclipboard.h>\fR.PPInherits QObject..PP.SS "Public Members".in +1c.ti -1c.BI "void \fBclear\fR ()".br.ti -1c.BI "bool \fBsupportsSelection\fR () const".br.ti -1c.BI "bool \fBownsSelection\fR () const".br.ti -1c.BI "bool \fBownsClipboard\fR () const".br.ti -1c.BI "void \fBsetSelectionMode\fR ( bool enable )".br.ti -1c.BI "bool \fBselectionModeEnabled\fR () const".br.ti -1c.BI "QMimeSource * \fBdata\fR () const".br.ti -1c.BI "void \fBsetData\fR ( QMimeSource * src )".br.ti -1c.BI "QString \fBtext\fR () const".br.ti -1c.BI "QString \fBtext\fR ( QCString & subtype ) const".br.ti -1c.BI "void \fBsetText\fR ( const QString & text )".br.ti -1c.BI "QImage \fBimage\fR () const".br.ti -1c.BI "QPixmap \fBpixmap\fR () const".br.ti -1c.BI "void \fBsetImage\fR ( const QImage & image )".br.ti -1c.BI "void \fBsetPixmap\fR ( const QPixmap & pixmap )".br.in -1c.SS "Signals".in +1c.ti -1c.BI "void \fBselectionChanged\fR ()".br.ti -1c.BI "void \fBdataChanged\fR ()".br.in -1c.SH DESCRIPTIONThe QClipboard class provides access to the window system clipboard..PPThe clipboard offers a simple mechanism to copy and paste data between applications..PPQClipboard supports the same data types that QDragObject does, and uses similar mechanisms. For advanced clipboard usage, you should read the drag-and-drop documentation..PPThere is a single QClipboard object in an application, and you can access it using QApplication::clipboard()..PPExample:.PP.nf.br QClipboard *cb = QApplication::clipboard();.br QString text;.br.br // Copy text from the clipboard (paste).br text = cb->text();.br if ( text ).br qDebug( "The clipboard contains: %s", text );.br.br // Copy text into the clipboard.br cb->setText( "This text can be pasted by other programs" );.br.fi.PPQClipboard features some convenience functions 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 setData() function is the ultimate in flexibility: it allows you to add any QMimeSource into the clipboard. (There are corresponding getters for each of these, e.g. text().).PPYou can clear the clipboard by calling clear()..PPThe underlying clipboards of the X Window system and MS Windows differ. The X Window system has a concept of selection -- when text is selected it is immediately available in the selection buffer; MS Windows only adds text to the clipboard when an explicit copy or cut is made. The X Window system also has a concept of ownership; if you change the selection within a window X11 will only notify the owner and the previous owner of the change; in MS Windows the clipboard is a fully global resource so all applications are notified of changes. See the multiclip example in the \fIQt Designer\fR examples directory for an example of a cross-platform clipboard application that also demonstrates selection handling..PPSee also Input/Output and Networking..SH MEMBER FUNCTION DOCUMENTATION.SH "void QClipboard::clear ()"Clears the clipboard contents..SH "QMimeSource * QClipboard::data () const"Returns a reference to a QMimeSource representation of the current clipboard data..SH "void QClipboard::dataChanged ()\fC [signal]\fR"This signal is emitted when the clipboard data is changed..SH "QImage QClipboard::image () const"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..PPSee also setImage(), pixmap(), data() and QImage::isNull()..SH "bool QClipboard::ownsClipboard () const"Returns TRUE is this clipboard object owns the clipboard data, FALSE otherwise..SH "bool QClipboard::ownsSelection () const"Returns TRUE if this clipboard object owns the mouse selection data, FALSE otherwise..SH "QPixmap QClipboard::pixmap () const"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..PPSee also setPixmap(), image(), data() and QPixmap::convertFromImage()..SH "void QClipboard::selectionChanged ()\fC [signal]\fR"This signal is emitted when the selection is changed. This only applies to windowing systems that support selections, e.g. X11. Windows doesn't support selections..SH "bool QClipboard::selectionModeEnabled () const"Returns the value set by setSelectionMode()..PPSee also setSelectionMode() and supportsSelection()..SH "void QClipboard::setData ( QMimeSource * src )"Sets the clipboard data to \fIsrc\fR. Ownership of the data is transferred to the clipboard. If you want to remove the data either call clear() or call setData() again with new data..PPThe QDragObject subclasses are reasonable objects to put into the clipboard (but do not try to call QDragObject::drag() on the same object). Any QDragObject placed in the clipboard should have a parent of 0. Do not put QDragMoveEvent or QDropEvent subclasses in the clipboard, as they do not belong to the event handler which receives them..PPThe setText() and setPixmap() functions are simpler wrappers for setting text and image data respectively..SH "void QClipboard::setImage ( const QImage & image )"Copies \fIimage\fR into the clipboard..PPThis is shorthand for:.PP.nf.br setData(new QImageDrag(image)).br.fi.PPSee also image(), setPixmap() and setData()..SH "void QClipboard::setPixmap ( const QPixmap & pixmap )"Copies \fIpixmap\fR into the clipboard. Note that this is slower than setImage() - it needs to convert the QPixmap to a QImage first..PPSee also pixmap(), setImage() and setData()..SH "void QClipboard::setSelectionMode ( bool enable )"Sets the clipboard selection mode. If \fIenable\fR is TRUE, then subsequent calls to QClipboard::setData() and other functions which put data into the clipboard will put the data into the mouse selection, otherwise the data will be put into the clipboard..PPSee also supportsSelection() and selectionModeEnabled()..SH "void QClipboard::setText ( const QString & text )"Copies \fItext\fR into the clipboard as plain text..PPSee also text() and setData()..SH "bool QClipboard::supportsSelection () const"Returns TRUE if the clipboard supports mouse selection, FALSE otherwise..SH "QString QClipboard::text ( QCString & subtype ) const"Returns the clipboard text in subtype \fIsubtype\fR, or a null string if the clipboard does not contain any text. If \fIsubtype\fR is null, any subtype is acceptable, and \fIsubtype\fR is set to the chosen subtype..PPCommon values for \fIsubtype\fR are "plain" and "html"..PPSee also setText(), data() and QString::operator!()..SH "QString QClipboard::text () const"This is an overloaded member function, provided for convenience. It behaves essentially like the above function..PPReturns the clipboard text as plain text, or a null string if the clipboard does not contain any text..PPSee also setText(), data() and QString::operator!()..SH "SEE ALSO".BR http://doc.trolltech.com/qclipboard.html.BR http://www.trolltech.com/faq/tech.html.SH COPYRIGHTCopyright 1992-2001 Trolltech AS, http://www.trolltech.com. See thelicense file included in the distribution for a complete licensestatement..SH AUTHORGenerated automatically from the source code..SH BUGSIf you find a bug in Qt, please report it as described in.BR http://doc.trolltech.com/bughowto.html .Good bug reports help us to help you. Thank you..PThe definitive Qt documentation is provided in HTML format; it islocated at $QTDIR/doc/html and can be read using Qt Assistant or witha web browser. This man page is provided as a convenience for thoseusers who prefer man pages, although this format is not officiallysupported by Trolltech. .PIf you find errors in this manual page, please report them to.BR qt-bugs@trolltech.com .Please include the name of the manual page (qclipboard.3qt) and the Qtversion (3.0.0).
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -