PDA

View Full Version : setting html for textbrowser



addu
8th October 2009, 10:53
Hi all

I want to set the text in between rectangular..

code is


QString html,text;
html = "<html><head><body><div style=width: 1000px; height:1500px; border: 1ex solid black>Text </div></body></html>";

/
// Crate a QTextDocument with the defined HTML, CSS and the images
QTextDocument *doc = new QTextDocument;

/*
* This shows how to bind the images, where the name for QUrl is the same name
* which you use in your HTML and CSS. In QPixmap just use the normal syntax of
* the Qt resource system.
*/


/*
* And now bind the css, which you have defined in the QString css.
*/
doc->addResource( QTextDocument::StyleSheetResource, QUrl( "format.css" ), css );
doc->setHtml( html ); // binds the HTML to the QTextDocument

/*
* This QTextDocument can now set to any QTextBrowser.
*/
QTextBrowser *tb = new QTextBrowser( 0 );
ui->textBrowser->setDocument( doc );


Here i don't the rectangle.


please help me

Thanks

Yuvaraj R

faldzip
8th October 2009, 11:01
put the style attruibute value in double quotes, like this:


<div style="width: 1000px; height: 1500px; ...">

addu
8th October 2009, 11:21
Hi tried with

but i am getting errors..


html = <div style="width: 1000px; height:1500px; border: 1ex solid black">+QString("ghjhgj")+</div>;

Please help me


Thanks

Yuvaraj R

faldzip
8th October 2009, 12:02
:eek: do you know how assign string value to a variable in C/C++???

addu
9th October 2009, 06:51
Hi
still don't get rectangle


ui->textBrowser->setHtml("<div style=\"width: 400px; height: 30px; border: 1ex solid black\">hello</div>");

Thanks

Yuvaraj R

ChrisW67
9th October 2009, 07:45
The supoprted subset (http://doc.trolltech.com/4.5/richtext-html-subset.html) of HTML in QTextBrowser does not seem to include borders for anything except tables.

addu
9th October 2009, 07:54
if i remove the the border value. will it work ?

I want create insert text with in rectangle in Text browser

Thanks

Yuvaraj R

faldzip
9th October 2009, 08:06
then create a table in HTML or use QWebView instead of QTextBrowser

addu
9th October 2009, 08:16
Actually

This component for Chat window.

That's why i am using QTextBrowser.

Thanks

Yuvaraj R