문제

I can get the line number of a cursor in a QTextEdit. but can't achieve to get the column number information. (Note: I use QTextBlock while getting line number info.) Isn't there an easy way to obtain column number? What should i do? Although i read here and here, QTextBlock class is still confusing me.

도움이 되었습니까?

해결책

This is my solution to the problem:

QTextCursor cursor = ui.textEdit->textCursor();
int y = cursor.blockNumber() + 1;
int x = cursor.columnNumber() + 1;
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top