#include#include #include int main(int argc, char *argv[]) { QApplication a(argc, argv); // Create an instance of QClipboard QClipboard *clipboard = QApplication::clipboard(); // Set some text in the clipboard clipboard->setText("Hello, World!"); // Clear the contents of the clipboard clipboard->clear(); // Check if the clipboard contains any text if (clipboard->text().isEmpty()) { qDebug() << "Clipboard is empty"; } return a.exec(); }
#includeIn this example, an instance of QClipboard is created using the QGuiApplication::clipboard() method. The setImage() method is called to set an image in the clipboard. The clear() method is called to clear the contents of the clipboard. Package/Library: This is a part of the Qt framework, therefore the package/library is Qt.#include #include int main(int argc, char *argv[]) { QGuiApplication a(argc, argv); // Create an instance of QClipboard QClipboard *clipboard = QGuiApplication::clipboard(); // Set an image in the clipboard clipboard->setImage(QImage("image.png")); // Clear the contents of the clipboard clipboard->clear(); return a.exec(); }