QClipboard *clipboard = QApplication::clipboard(); QImage image("example.png"); clipboard->setImage(image);
QClipboard *clipboard = QApplication::clipboard(); QPixmap pixmap("example.jpg"); QImage image = pixmap.toImage(); clipboard->setImage(image);
#includeThis code sets the image "example.bmp" as the clipboard's data using a QGuiApplication object. Package library: Qt Core Module.#include int main(int argc, char *argv[]) { QGuiApplication app(argc, argv); QClipboard *clipboard = QGuiApplication::clipboard(); QImage image("example.bmp"); clipboard->setImage(image); return app.exec(); }