
void
Widget::keyPressEvent(QKeyEvent
event)
{
switch
(event->key())
{
case
Qt::Key_Return:
focusNextPrevChild(true);
break;}
}
focusNextPrevChild(true);这是选下一个焦点的,返回当前的就在这附近,你帮助里找下,我就帮你找了。
可以使用QTextCursor和QTextCharFormat:
QTextEdit edit = new QTextEdit;int begin =
int end =
QTextCharFormat fmt;
fmtsetBackground(Qt::yellow);
QTextCursor cursor(edit->document());
cursorsetPosition(begin, QTextCursor::MoveAnchor);
cursorsetPosition(end, QTextCursor::KeepAnchor);
cursorsetCharFormat(fmt);
这是我从stackoverflow上搬来了。。。how to highlight a string of text within a qtextedit
以上就是关于Qt中如何获取当前焦点控件全部的内容,包括:Qt中如何获取当前焦点控件、Qt中关于QTextEdit的问题,如何获取选中其中某个位置数据呢、等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)