Improve the sample code

maybe you forgot this line

Change-Id: I1f5abd08023bd344e5bb2bf811b6195cbcf61dff
Reviewed-by: Christian Ehrlicher <ch.ehrlicher@gmx.de>
This commit is contained in:
Fan PengCheng 2021-03-19 11:05:33 +08:00
parent 969337bcfd
commit 7b62b846ae

View File

@ -90,14 +90,19 @@ ClipWindow::ClipWindow(QWidget *parent)
//! [1]
void ClipWindow::updateClipboard()
{
mimeTypeCombo->clear();
QStringList formats = clipboard->mimeData()->formats();
if (formats.isEmpty())
return;
for (const auto &format : formats) {
QByteArray data = clipboard->mimeData()->data(format);
// ...
}
//! [1]
mimeTypeCombo->clear();
mimeTypeCombo->addItems(formats);
int size = clipboard->mimeData()->data(formats[0]).size();
QListWidgetItem *newItem = new QListWidgetItem(previousItems);