Results 1 to 2 of 2

Thread: QString is a richText or plain text

  1. #1
    Join Date
    Aug 2008
    Posts
    11
    Thanks
    1

    Unhappy QString is a richText or plain text

    Hi, all
    I'm using a QTextEdit which is used for display a string on my application ,how do i know the string is richText ,or just plain text ,so I can choose two ways to process it ,any idea, thanks!

  2. #2
    Join Date
    Jun 2009
    Posts
    6
    Thanked 3 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: QString is a richText or plain text

    Why don't you just pass your string to the QTextEdit using the setHtml function?

    If the string contains any HTML markup, then QTextEdit will use this to format the text, if not, it will - well - just show the text.

    You can however (in case you want to know this for processing independent of displaying the text in the QTextEdit), use the Qt::mightBeRichText function on any QString. The function checks whether the text of the QString contains something that looks like rich text markup (HTML tags, basically).

Similar Threads

  1. Unhandled exception in qatomic
    By NewGuy in forum Qt Programming
    Replies: 14
    Last Post: 23rd July 2013, 09:49
  2. Qy 4.4.3 MySQL driver failed
    By pamalite in forum Installation and Deployment
    Replies: 2
    Last Post: 23rd January 2010, 01:09
  3. QTextEdit + paste rich text as plain text only
    By Yong in forum Qt Programming
    Replies: 2
    Last Post: 6th February 2008, 16:45
  4. Convert from iso-8859-1 to... Something else :-)
    By Nyphel in forum Qt Programming
    Replies: 4
    Last Post: 7th March 2007, 17:59
  5. QTextEdit API questions (plain text)
    By Gaspar in forum Qt Programming
    Replies: 4
    Last Post: 16th May 2006, 06:03

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.