Posts Tagged ‘QTextLayout’

QPlainTextEdit获得当前光标行的行号

QTextDocument的结构之复杂是不用不知道, 一用吓一跳。 连获得光标行号这么个简单问题都要拐上七八个弯。
下面是一个比较标准的解决方案:
//get the current line number
QTextCursor tc = edit->textCursor();//当前行的光标
QTextLayout* lo = tc.block().layout();
//get the relative position in the block
[...]

Read More...

Tags: , , ,
Posted on July 8th, 2010 in C++, Qt技术 | 1 Comment ».