Results 1 to 3 of 3

Thread: QTextDocument and HTML tags

  1. #1
    Join Date
    Dec 2011
    Posts
    2
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default QTextDocument and HTML tags

    Hi,

    I have a QTextDocument (in an QTextEdit) that contains HTML formatted text. Based on the enclosing tag (if any) I need to perform different tasks when the user presses the enter key.

    How can I get the enclosing tag?

    /Regards

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: QTextDocument and HTML tags

    I assume you mean the text visible to the user is HTML.

    A naive approach: Look backward for the most recent open tag (if any), look forward for the next close tag (if any), if you have two tags and they match then you have your answer.

    Were you expecting a Qt supplied findTheEndTagIfAny() function?

  3. #3
    Join Date
    Dec 2011
    Posts
    2
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QTextDocument and HTML tags

    Hi,

    no I mean that the user visible text is formatted using HTML but shown as in a WYSIWYG editor.

    However if this means that the text that I can access contains the tags then it will be easy. But I kinda assumed that the html is converted into some formatting hidden inside some propertied associated with the different blocks/frames.

    /Regards

Similar Threads

  1. how to use html tags(rich text) in QTableWidgetHeaderItem
    By ansmehta in forum Qt Programming
    Replies: 0
    Last Post: 13th December 2010, 10:20
  2. QRegExp for extracting the string between two HTML tags...
    By tuthmosis in forum Qt Programming
    Replies: 3
    Last Post: 27th May 2010, 06:55
  3. Matching HTML tags
    By pucara_faa in forum Qt Programming
    Replies: 4
    Last Post: 22nd January 2010, 13:19
  4. Html tags in QTreeView
    By 1111 in forum Qt Programming
    Replies: 1
    Last Post: 13th March 2009, 01:41
  5. QFontMetrics and HTML tags
    By vonCZ in forum Newbie
    Replies: 1
    Last Post: 14th August 2008, 12:13

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.