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. count chars in line QTextEdit
Forum Updated to NodeBB v4.3 + New Features

count chars in line QTextEdit

Scheduled Pinned Locked Moved Unsolved General and Desktop
4 Posts 2 Posters 454 Views 1 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.
  • M Offline
    M Offline
    Martinuccia_96
    wrote on last edited by
    #1

    Hi, everyone.
    Let's considering a qTextEditBlock.
    By using the QTextCursor, is there any way to count the number of chars present in a line?
    I move on the line where I want to count the chars in the following way:

    QTextCursor curs=ui->textEdit->textCursor();
    curs.movePosition(QTextCursor::Start);
    curs.movePosition(QTextCursor::NextBlock,QTextCursor::MoveAnchor, line)
    

    where line is an integer that indicates the block in which I want to move.
    Now, how can I do?
    Thanks to everyone

    raven-worxR 1 Reply Last reply
    0
    • M Martinuccia_96

      Hi, everyone.
      Let's considering a qTextEditBlock.
      By using the QTextCursor, is there any way to count the number of chars present in a line?
      I move on the line where I want to count the chars in the following way:

      QTextCursor curs=ui->textEdit->textCursor();
      curs.movePosition(QTextCursor::Start);
      curs.movePosition(QTextCursor::NextBlock,QTextCursor::MoveAnchor, line)
      

      where line is an integer that indicates the block in which I want to move.
      Now, how can I do?
      Thanks to everyone

      raven-worxR Offline
      raven-worxR Offline
      raven-worx
      Moderators
      wrote on last edited by raven-worx
      #2

      @Martinuccia_96

      curs.block().length()
      

      --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
      If you have a question please use the forum so others can benefit from the solution in the future

      1 Reply Last reply
      2
      • M Offline
        M Offline
        Martinuccia_96
        wrote on last edited by
        #3

        but what if the number of chars is lower than the block length? For example if I push the enter button on the keyboard..

        raven-worxR 1 Reply Last reply
        0
        • M Martinuccia_96

          but what if the number of chars is lower than the block length? For example if I push the enter button on the keyboard..

          raven-worxR Offline
          raven-worxR Offline
          raven-worx
          Moderators
          wrote on last edited by
          #4

          @Martinuccia_96
          then its a new block

          --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
          If you have a question please use the forum so others can benefit from the solution in the future

          1 Reply Last reply
          2

          • Login

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