diff --git a/src/gui/doc/snippets/clipboard/clipwindow.cpp b/src/gui/doc/snippets/clipboard/clipwindow.cpp index 2ec10ec649..ae31d01383 100644 --- a/src/gui/doc/snippets/clipboard/clipwindow.cpp +++ b/src/gui/doc/snippets/clipboard/clipwindow.cpp @@ -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);