Results 1 to 9 of 9

Thread: setting html for textbrowser

  1. #1
    Join Date
    May 2009
    Posts
    129

    Default setting html for textbrowser

    Hi all

    I want to set the text in between rectangular..

    code is

    Qt Code:
    1. QString html,text;
    2. html = "<html><head><body><div style=width: 1000px; height:1500px; border: 1ex solid black>Text </div></body></html>";
    3.  
    4. /
    5. // Crate a QTextDocument with the defined HTML, CSS and the images
    6.  
    7. /*
    8.  * This shows how to bind the images, where the name for QUrl is the same name
    9.  * which you use in your HTML and CSS. In QPixmap just use the normal syntax of
    10.  * the Qt resource system.
    11.  */
    12.  
    13.  
    14. /*
    15.  * And now bind the css, which you have defined in the QString css.
    16.  */
    17. doc->addResource( QTextDocument::StyleSheetResource, QUrl( "format.css" ), css );
    18. doc->setHtml( html ); // binds the HTML to the QTextDocument
    19.  
    20. /*
    21.  * This QTextDocument can now set to any QTextBrowser.
    22.  */
    23. QTextBrowser *tb = new QTextBrowser( 0 );
    24. ui->textBrowser->setDocument( doc );
    To copy to clipboard, switch view to plain text mode 

    Here i don't the rectangle.


    please help me

    Thanks

    Yuvaraj R

  2. #2
    Join Date
    Jan 2008
    Location
    Poland
    Posts
    687
    Thanks
    4
    Thanked 140 Times in 132 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: setting html for textbrowser

    put the style attruibute value in double quotes, like this:
    Qt Code:
    1. <div style="width: 1000px; height: 1500px; ...">
    To copy to clipboard, switch view to plain text mode 
    I would like to be a "Guru"

    Useful hints (try them before asking):
    1. Use Qt Assistant
    2. Search the forum

    If you haven't found solution yet then create new topic with smart question.

  3. #3
    Join Date
    May 2009
    Posts
    129

    Default Re: setting html for textbrowser

    Hi tried with

    but i am getting errors..

    Qt Code:
    1. html = <div style="width: 1000px; height:1500px; border: 1ex solid black">+QString("ghjhgj")+</div>;
    To copy to clipboard, switch view to plain text mode 

    Please help me


    Thanks

    Yuvaraj R

  4. #4
    Join Date
    Jan 2008
    Location
    Poland
    Posts
    687
    Thanks
    4
    Thanked 140 Times in 132 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: setting html for textbrowser

    do you know how assign string value to a variable in C/C++???
    I would like to be a "Guru"

    Useful hints (try them before asking):
    1. Use Qt Assistant
    2. Search the forum

    If you haven't found solution yet then create new topic with smart question.

  5. #5
    Join Date
    May 2009
    Posts
    129

    Default Re: setting html for textbrowser

    Hi
    still don't get rectangle

    Qt Code:
    1. ui->textBrowser->setHtml("<div style=\"width: 400px; height: 30px; border: 1ex solid black\">hello</div>");
    To copy to clipboard, switch view to plain text mode 

    Thanks

    Yuvaraj R

  6. #6
    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: setting html for textbrowser

    The supoprted subset of HTML in QTextBrowser does not seem to include borders for anything except tables.

  7. #7
    Join Date
    May 2009
    Posts
    129

    Default Re: setting html for textbrowser

    if i remove the the border value. will it work ?

    I want create insert text with in rectangle in Text browser

    Thanks

    Yuvaraj R

  8. #8
    Join Date
    Jan 2008
    Location
    Poland
    Posts
    687
    Thanks
    4
    Thanked 140 Times in 132 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: setting html for textbrowser

    then create a table in HTML or use QWebView instead of QTextBrowser
    I would like to be a "Guru"

    Useful hints (try them before asking):
    1. Use Qt Assistant
    2. Search the forum

    If you haven't found solution yet then create new topic with smart question.

  9. #9
    Join Date
    May 2009
    Posts
    129

    Default Re: setting html for textbrowser

    Actually

    This component for Chat window.

    That's why i am using QTextBrowser.

    Thanks

    Yuvaraj R

Similar Threads

  1. QtWebKit access HTML manipulated by javascript
    By rbp in forum Qt Programming
    Replies: 1
    Last Post: 19th September 2009, 02:29
  2. add custom HTML attribute by javascript in QtWebKit
    By sand.fj.wen in forum Qt Programming
    Replies: 3
    Last Post: 17th April 2009, 07:25
  3. Special character's HTML entity to string
    By Hiba in forum Qt Programming
    Replies: 4
    Last Post: 3rd March 2009, 14:05
  4. QFontMetrics and HTML tags
    By vonCZ in forum Newbie
    Replies: 1
    Last Post: 14th August 2008, 12:13
  5. Loading images in html in a QTextBrowser
    By BasicPoke in forum Newbie
    Replies: 1
    Last Post: 6th June 2007, 21:51

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.