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 get CharFormat from each char
Forum Updated to NodeBB v4.3 + New Features

How to get CharFormat from each char

Scheduled Pinned Locked Moved General and Desktop
3 Posts 3 Posters 1.7k 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.
  • P Offline
    P Offline
    Pablik2005
    wrote on last edited by
    #1

    hi, i need get CharFormat () from each char in QTextEdit, but i dont know how.

    If i will know method who selectChar(int Char), then will by lock some like that:
    [code]
    for(int i=0; i<ui->TextEdit->toPlaintext.lenght(); i++)
    {
    selectChar(i);
    currentCharFormat ()// and here return charFormat()
    }
    [/code]

    1 Reply Last reply
    0
    • J Offline
      J Offline
      jalomic
      wrote on last edited by
      #2

      CharFormat ? What does it mean ?

      1 Reply Last reply
      0
      • A Offline
        A Offline
        acethewd
        wrote on last edited by
        #3

        This might get you what you are looking for.

        @QTextCursor cur(TextEdit->document());
        QTextCharFormat charformat;

        for (int i = 1; i <= TextEdit->length(); i++)
        {
        cur.setPosition(i);
        charformat = cur.charFormat();
        }
        @

        The setPosition method doesn't state what index it starts from but I think index 0 would be before the first character in your document and index = length() would be right after the last character.

        1 Reply Last reply
        0

        • Login

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