复制到C ++中的剪贴板? [英] Copy to clipboard in C++?
问题描述
我想在我的C ++应用程序中将一些字符串复制到剪贴板。
我该怎么做?
还可以复制格式吗?
谢谢
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
推荐答案
您说您在评论之一中使用了Qt。
You said you use Qt in one of your comments.
Qt具有类 QClipboard ,这是您想要的(奖励) :这是跨平台的。)
Qt has the class QClipboard, which is what you want (bonus: this is cross-platform).
您几乎可以放任何东西,数据通过MIME类型进行管理。这意味着您可以使用自定义 MIME类型在剪贴板中使用自己的数据格式。请注意,格式设置通常使用html文本( text / html
)完成,而纯文本位于 text / plain
(对于纯文本,Qt提供了 text()
)函数。
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()
).
这篇关于复制到C ++中的剪贴板?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!