Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How to find current line number in QTextEdit?
Forum Updated to NodeBB v4.3 + New Features

How to find current line number in QTextEdit?

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 2 Posters 4.5k Views 3 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • N Offline
    N Offline
    Nastya Medvedeva
    wrote on last edited by
    #1

    I need to get a position of a text cursor in QTextEdit counted in number of lines.
    In the docs I can only see textCursor().position() function which counts it in characters.

    I also found the QTextLayout class, with has lineForTextPosition() function, but i am not sure if it is what I am looking for, as according to help it serves purpose of putting text into widgets of various shapes and looks like huge overkill to my purposes.

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      The solution proposed here might be what you are looking for.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      3

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved