PDA

View Full Version : QPlainTextEdit - "real" column number



Carlsberg
22nd May 2009, 08:08
I am trying to get the cursor position in a QPlainTextEdit. So I get the the cursor object and the call columnNumber().

The problem appears where I have tab characters on that line.

At the end of the line for a text like this

AB

columnNumber() returns 2

If I have a tab 4 characters long

[TAB4]AB

columnNumber() returns 3, but I need the "real" column number -> 6

Is there a function that returns that value?

wysota
22nd May 2009, 12:53
The real column number is 3 :) You can react on tab key and substitute the tabulator character with an appropriate number of spaces. Then the value will be returned as you want it. If that's not an option then you can always calculate the position yourself.