开发者

How to send "Ctrl + C" event to a Qt widget?

I want to a "Ctrl+C" event to a Qt widget, say a QLineEdit when the person presses the copy icon of my application. How should I do it ? Will it make QLineEdit do what it does when a user specifically presses "Ctrl + C" (i.e. copy) ?

Just a clarification : The widget may not be QLineEdit. In one of the cases, its is QWebView. Now, it displays a Web page, in which there may be text fields of its own. I want to paste something on those 开发者_Go百科text fields. That is only possible if those text fields embedded inside the web page feel that the user has presses "Ctrl+V".


QCoreApplication::postEvent with two QKeyEvents (QEvent::KeyPress and QEvent::KeyRelease)


    QKeyEvent * evt = new QKeyEvent(QEvent::Type::KeyPress, Qt::Key_C, Qt::ControlModifier); 
    QCoreApplication::postEvent(target_widget, evt);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜