#include#include #include int main(int argc, char *argv[]) { QApplication app(argc, argv); QClipboard *clipboard = QApplication::clipboard(); QString text = "Hello, world!"; clipboard->setText(text); return app.exec(); }
#includeThis code retrieves the current clipboard contents and outputs them to the console using the qDebug function. The text is stored in the QString variable "text". The QApplication and QClipboard classes are used as in the previous example. The library that contains the QClipboard class is the Qt GUI library. This library provides a variety of graphical user interface components and functionality for developing cross-platform applications.#include #include int main(int argc, char *argv[]) { QApplication app(argc, argv); QClipboard *clipboard = QApplication::clipboard(); QString text = clipboard->text(); qDebug() << text; return app.exec(); }