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 the index of a string in block when I have the index of the string in the WHOLE text
Forum Update on Monday, May 27th 2025

How to find the index of a string in block when I have the index of the string in the WHOLE text

Scheduled Pinned Locked Moved Solved General and Desktop
2 Posts 2 Posters 159 Views
  • 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.
  • F Offline
    F Offline
    Fuchsiaff
    wrote on 15 Aug 2019, 18:31 last edited by
    #1

    So I have a QPlainTextEdit which is filled with text and I have the index of a string and that index represents its position in the whole QPlainTextEdit text area

    But how do I get that index position in the block where that piece of text resides?

    1 Reply Last reply
    0
    • F Offline
      F Offline
      fcarney
      wrote on 15 Aug 2019, 18:47 last edited by
      #2

      Subtract that start of the index of the block from the index of the string. That should convert the coordinates to block coordinates vs whole string coordinates. Then make sure that the new index does not exceed the length of the block.

      C++ is a perfectly valid school of magic.

      1 Reply Last reply
      3

      1/2

      15 Aug 2019, 18:31

      • Login

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