PDA

View Full Version : Printing the content



veda
13th September 2007, 07:20
Hello All,

I want to print the content of the QTextEdit ,but the problem is
I have a rich text in QTextEdit when I try to print the text of this QTextEdit
It prints the HTML tags along with the content,

I don't want to print the tags, nor as a plain text...
But as a richText with the same font , size ,Color.... as seen in the QTextEdit .

Thanks,

vermarajeev
13th September 2007, 07:30
How r u printing the data? Did you look some of the examples given in assistant.
I could find the following.


void MainWindow::print()
{
QTextDocument *document = textEdit->document();
QPrinter printer;

QPrintDialog *dlg = new QPrintDialog(&printer, this);
if (dlg->exec() != QDialog::Accepted)
return;

document->print(&printer);

statusBar()->showMessage(tr("Ready"), 2000);
}

joshlareau
25th September 2007, 19:22
I'm experiencing the same problem. I have a QString that has an HTML table, but when I construct a QTextDocument and call print on it, I get a printout of the HTML, not of the table. What am I doing wrong?

wysota
25th September 2007, 19:40
Did you tell the document that it contains rich text? For instance by using QTextDocument::setHtml.

kommu
27th December 2007, 08:19
I am having the same problem which should print html content on embedded machine.

My qt version is 3.3.4. It doesn't have QTextDocument, QPrintDialog.

Please tell me how to print

wysota
27th December 2007, 11:15
There is no easy way of doing that in Qt 3.

veda
27th December 2007, 11:53
Try using QSimpleRichText::draw function

wysota
27th December 2007, 12:03
Just remember it won't divide the text into pages. You have to draw each page separately.