Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Copy to clipboard in C++? [duplicate]

Tags:

c++

clipboard

qt

I want to copy some string to clipboard in my C++ application. How can I do that? Also is it possible to copy the formatting as well? Thank You

like image 597
Cool_Coder Avatar asked Dec 09 '22 16:12

Cool_Coder


1 Answers

You said you use Qt in one of your comments.

Qt has the class QClipboard, which is what you want (bonus: this is cross-platform).

You can put almost anything you want, data is managed via MIME types. That means you can use your own data formatting in the clipboard, with a 'custom' MIME type. Note that formatting is usually done with html text (text/html), whereas plain text is in text/plain (for plain text Qt provides the function text()).

like image 91
Synxis Avatar answered Dec 11 '22 06:12

Synxis