It is necessary to catch the moment of copying text to the clipboard from any application, receive this text and take a certain action. Tell me which way to dig? On the Internet, I did not find anything (I was looking bad?)
1 answer
Here is an example of a small clipboard watcher.
#include <QClipboard> #include <QApplication> #include <QTextEdit> class ClipboardWatcher : public QTextEdit{ Q_OBJECT public: explicit ClipboardWatcher(QWidget *parent = 0): QTextEdit(parent) { connect(QApplication::clipboard(), SIGNAL(dataChanged()), this, SLOT(_setClipboardText())); setWindowFlags(Qt::WindowStaysOnTopHint); } private slots: void _setClipboardText(){ setText(QApplication::clipboard()->text()); } };
|