当前位置: 代码迷 >> QT开发 >> 关于QTextEdit中获取光标所在句子的内容解决方法
  详细解决方案

关于QTextEdit中获取光标所在句子的内容解决方法

热度:217   发布时间:2016-04-25 05:09:35.0
关于QTextEdit中获取光标所在句子的内容
假如在一个QTextEdit里,有一段文字:  
As is known to all, migrant workers have made a great contribution to the prosperity of cities. They are an indispensable part of our workforce. Most of them work on construction sites. There is no doubt that without migrant workers many of the construction projects would have to be held up for lack of manpower. In addition, a large number of migrant workers is a factor which stimulates the consumption of food and daily items. This helps to develop food industry and service trades in cities. All these are positive aspects of migrant workers in cities. 
假如我把光标放在红色句子的任意一处,则获取该红色句子的内容到一个QString变量中。如何实现?

------解决方案--------------------
void QTextEdit::cursorPositionChanged ( int para, int pos ) [信号]一旦光标移动则这个信号会被发射,其中包含光标所在段落 以及位置。 剩下的你懂了吧……
  相关解决方案