0
有沒有辦法獲取QTextWidget中文本光標的當前行號?我看不到來查找documentation.pyqt:獲取文本光標的當前行號
有沒有辦法獲取QTextWidget中文本光標的當前行號?我看不到來查找documentation.pyqt:獲取文本光標的當前行號
什麼這已經在How to get column number in qtextedit?
QTextCursor cursor = ui.textEdit->textCursor();
int y = cursor.blockNumber() + 1;
int x = cursor.columnNumber() + 1;
回答參加一個[博客帖]看看numberbarPaint功能(http://john.nachtimwald.com/2009/08/19 /更好-qplaintextedit與 - 線數/)。顯然你可以使用'textCursor'的'position'方法。另請參閱[職位文檔](http://pyqt.sourceforge.net/Docs/PyQt4/qtextcursor.html#position)瞭解不同的選項。 –