How to Copy to Clipboard with C++
Excellent for creating those GUI buttons: ▣ Copy / ✔ Copied!
There are several C++ libraries to do this. But each one has its own peculiarities, however, we will mention the majority at the end of this article.
In this example we will see how to use Clip.
The simplest way to use is:
1. Create an example project and enter it:
2. Clone the Clip for your project:
3. Create a basic C++ file that, after running the binary, will copy the
4. Create a CMake to build the binary:
Change the CMake version to your version, I put this version for compatibility reasons, but there will probably be a warning when running it, but it will work!
When running the binary, try typing:
Ctrl + v somewhere else and notice that the content was copied!
NOTE: This may not work in window managers, you need to configure files for compatibility, despite the xclip command work normally!
But, I tested it on GNOME and Windows and it worked perfectly!
For more information, visit the Clip repository.
And as I said, there are many options for it, including: