本文整理汇总了C++中QClipboardData::setSource方法的典型用法代码示例。如果您正苦于以下问题:C++ QClipboardData::setSource方法的具体用法?C++ QClipboardData::setSource怎么用?C++ QClipboardData::setSource使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QClipboardData
的用法示例。
在下文中一共展示了QClipboardData::setSource方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: setMimeData
void QClipboard::setMimeData(QMimeData* src, Mode mode)
{
if (mode != Clipboard) return;
QClipboardData *d = clipboardData();
/* Propagate text data to other QWSClients */
QString newText;
if( src != 0 )
newText = src->text();
QString oldText;
if( d->source() != 0 )
oldText = d->source()->text();
d->setSource(src);
if( oldText != newText ) {
if( d->source() == 0 ) {
qwsSetClipboardText( QString() );
} else {
qwsSetClipboardText( d->source()->text() );
}
}
emitChanged(QClipboard::Clipboard);
}
示例2: mimeData
const QMimeData* QClipboard::mimeData(Mode mode) const
{
QClipboardData *d = 0;
switch (mode) {
case Selection:
d = selectionData();
break;
case Clipboard:
d = clipboardData();
break;
default:
qWarning("QClipboard::mimeData: unsupported mode '%d'", mode);
return 0;
}
if (! d->source() && ! timer_event_clear) {
if (mode == Selection) {
if (! selection_watcher)
selection_watcher = new QClipboardWatcher(mode);
d->setSource(selection_watcher);
} else {
if (! clipboard_watcher)
clipboard_watcher = new QClipboardWatcher(mode);
d->setSource(clipboard_watcher);
}
if (! timer_id) {
// start a zero timer - we will clear cached data when the timer
// times out, which will be the next time we hit the event loop...
// that way, the data is cached long enough for calls within a single
// loop/function, but the data doesn't linger around in case the selection
// changes
QClipboard *that = ((QClipboard *) this);
timer_id = that->startTimer(0);
}
}
return d->source();
}
示例3: mimeData
const QMimeData* QClipboard::mimeData(Mode mode) const
{
if (mode != Clipboard) return 0;
QClipboardData *d = clipboardData();
// Try and get data from QWSProperty if no mime data has been set on us.
if( !d->source() ) {
QString t = qwsClipboardText();
if( !t.isEmpty() ) {
QMimeData* nd = new QMimeData;
nd->setText( t );
d->setSource( nd );
}
}
return d->source();
}
示例4: event
bool QClipboard::event(QEvent *e)
{
static bool recursionWatch = false;
if (e->type() != QEvent::Clipboard || recursionWatch)
return QObject::event(e);
recursionWatch = true;
QWSPropertyNotifyEvent *event = (QWSPropertyNotifyEvent *)(((QClipboardEvent *)e)->data());
if (event && event->simpleData.state == QWSPropertyNotifyEvent::PropertyNewValue) {
QClipboardData *d = clipboardData();
QString t = qwsClipboardText();
if( (d->source() == 0 && !t.isEmpty()) || (d->source() != 0 && d->source()->text() != t) ) {
if( !d->source() )
d->setSource(new QMimeData);
d->source()->setText( t );
emitChanged(QClipboard::Clipboard);
}
}
recursionWatch = false;
return true;
}
示例5: setMimeData
void QClipboard::setMimeData(QMimeData* src, Mode mode)
{
Atom atom, sentinel_atom;
QClipboardData *d;
switch (mode) {
case Selection:
atom = XA_PRIMARY;
sentinel_atom = ATOM(_QT_SELECTION_SENTINEL);
d = selectionData();
break;
case Clipboard:
atom = ATOM(CLIPBOARD);
sentinel_atom = ATOM(_QT_CLIPBOARD_SENTINEL);
d = clipboardData();
break;
default:
qWarning("QClipboard::setMimeData: unsupported mode '%d'", mode);
return;
}
Display *dpy = X11->display;
Window newOwner;
if (! src) { // no data, clear clipboard contents
newOwner = XNone;
d->clear();
} else {
setupOwner();
newOwner = owner->internalWinId();
d->setSource(src);
d->timestamp = X11->time;
}
Window prevOwner = XGetSelectionOwner(dpy, atom);
// use X11->time, since d->timestamp == CurrentTime when clearing
XSetSelectionOwner(dpy, atom, newOwner, X11->time);
if (mode == Selection)
emitChanged(QClipboard::Selection);
else
emitChanged(QClipboard::Clipboard);
if (XGetSelectionOwner(dpy, atom) != newOwner) {
qWarning("QClipboard::setData: Cannot set X11 selection owner for %s",
X11->xdndAtomToString(atom).data());
d->clear();
return;
}
// Signal to other Qt processes that the selection has changed
Window owners[2];
owners[0] = newOwner;
owners[1] = prevOwner;
XChangeProperty(dpy, QApplication::desktop()->screen(0)->internalWinId(),
sentinel_atom, XA_WINDOW, 32, PropModeReplace,
(unsigned char*)&owners, 2);
}