Results 1 to 2 of 2

Thread: QPlainTextEdit - "real" column number

  1. #1
    Join Date
    May 2009
    Posts
    52
    Thanks
    4
    Qt products
    Qt4
    Platforms
    Windows

    Default QPlainTextEdit - "real" column number

    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?

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QPlainTextEdit - "real" column number

    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.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Similar Threads

  1. KDE/QWT doubt on debian sarge
    By hildebrand in forum KDE Forum
    Replies: 13
    Last Post: 25th April 2007, 06:13
  2. Replies: 0
    Last Post: 10th November 2006, 13:46
  3. How to get column number in a line
    By showhand in forum Qt Programming
    Replies: 1
    Last Post: 30th August 2006, 09:42
  4. hidden QListView column suddenly visible
    By edb in forum Qt Programming
    Replies: 10
    Last Post: 27th January 2006, 08:00

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.