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..
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..