Doc: Make Qt Gui snippets compilable - clipboard
Task-number: QTBUG-81486 Change-Id: I41b0c5f021ea9fbbe384f224443608f4397dec24 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>bb10
parent
49e8d0f3d5
commit
5e566d004e
|
|
@ -1,3 +1,10 @@
|
|||
HEADERS = clipwindow.h
|
||||
SOURCES = clipwindow.cpp \
|
||||
main.cpp
|
||||
TEMPLATE = lib
|
||||
TARGET = clipboard_snippets
|
||||
QT += core gui widgets
|
||||
|
||||
HEADERS = \
|
||||
clipwindow.h
|
||||
|
||||
SOURCES = \
|
||||
clipwindow.cpp \
|
||||
main.cpp
|
||||
|
|
|
|||
|
|
@ -49,6 +49,7 @@
|
|||
****************************************************************************/
|
||||
|
||||
#include <QtWidgets>
|
||||
#include <QMimeData>
|
||||
|
||||
#include "clipwindow.h"
|
||||
|
||||
|
|
@ -70,8 +71,6 @@ ClipWindow::ClipWindow(QWidget *parent)
|
|||
connect(clipboard, &QClipboard::dataChanged,
|
||||
this, &ClipWindow::updateClipboard);
|
||||
//! [0]
|
||||
connect(mimeTypeCombo, QOverload<QString>::of(&QComboBox::activated),
|
||||
this, &ClipWindow::updateData);
|
||||
|
||||
QVBoxLayout *currentLayout = new QVBoxLayout(currentItem);
|
||||
currentLayout->addWidget(mimeTypeLabel);
|
||||
|
|
@ -92,20 +91,20 @@ ClipWindow::ClipWindow(QWidget *parent)
|
|||
void ClipWindow::updateClipboard()
|
||||
{
|
||||
QStringList formats = clipboard->mimeData()->formats();
|
||||
QByteArray data = clipboard->mimeData()->data(format);
|
||||
for (const auto &format : formats) {
|
||||
QByteArray data = clipboard->mimeData()->data(format);
|
||||
// ...
|
||||
}
|
||||
//! [1]
|
||||
|
||||
mimeTypeCombo->clear();
|
||||
mimeTypeCombo->insertStringList(formats);
|
||||
|
||||
int size = clipboard->mimeData()->data(formats[0]).size();
|
||||
QListWidgetItem *newItem = new QListWidgetItem(previousItems);
|
||||
newItem->setText(tr("%1 (%2 bytes)").arg(formats[0]).arg(size));
|
||||
|
||||
updateData(formats[0]);
|
||||
//! [2]
|
||||
}
|
||||
//! [2]
|
||||
|
||||
void ClipWindow::updateData(const QString &format)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ SUBDIRS =
|
|||
contains(QT_BUILD_PARTS, tests) {
|
||||
SUBDIRS += \
|
||||
brush \
|
||||
clipboard \
|
||||
code \
|
||||
draganddrop \
|
||||
qfontdatabase \
|
||||
|
|
|
|||
|
|
@ -377,8 +377,6 @@
|
|||
using one of the MIME types that can be used to represent it:
|
||||
|
||||
\snippet clipboard/clipwindow.cpp 1
|
||||
\dots
|
||||
\snippet clipboard/clipwindow.cpp 2
|
||||
|
||||
The \l{QClipboard::selectionChanged()}{selectionChanged()} signal can
|
||||
be used on X11 to monitor the mouse selection.
|
||||
|
|
|
|||
Loading…
Reference in New Issue