PDA

View Full Version : Sync Width



wirasto
2nd December 2009, 12:46
How to synchronize QTextEdit width with QPrinter Paper width, and QTextEdit document margin with QPrinter page margin.

I not have a good method :(

Width like sync with this code. But I'm not sure.


//sync width
int mw=printer.paperSize(QPrinter::DevicePixel).width( );
ui->textEdit->setMaximumWidth(mw);



And code for sync margin still not work :(


//sync margin
printer.setPageMargins(20, 20, 20, 20, QPrinter::DevicePixel);
ui->textEdit->document()->setDocumentMargin(20);


//I use GIMP and get 1pixel is 0.35 millimeter
qreal aa=0.35 * 20.0;
printer.setPageMargins(aa, aa, aa, aa, QPrinter::Millimeter);
ui->textEdit->document()->setDocumentMargin(20);



Sorry, with my english..

wysota
3rd December 2009, 09:45
What do you mean by "sync"? The text edit is completely irrelevant. What is important is the text document it operates on. "Synchronize" the widget with the document and then print the document on the printer setup properly for the document size.