自从我为项目更新了qt 5.12以来,我遇到了一个问题。当我以A7纸张大小打印时,我在代码中编写的文本大小不再适合。有人可以解决这个问题吗?预先感谢
QPrinter printer;
printer.setPageSize(QPrinter::A7);
printer.setPageMargins(5,0,5,0,QPrinter::Millimeter);
printer.setFullPage(true);
QString sDate = QDateTime::currentDateTime().toString("dddd dd MMMM yyyy"); // date de la machine
QString sTime = QTime::currentTime().toString();; // temps de la machine
QTextDocument doc2;
QString TE2=zoneTexte2->toHtml()+"<br><div align='center'><b>CREDIT CARD ARVY</b> </div>"+"<div align='center'>_____________________</div><br>"+
+"<table width=100%><tr><td align='left'>Le "+sDate+"+sTime+"</td></tr>"+"<div align='";
QPrintDialog *dialog = new QPrintDialog(&printer, this);
ui->test->setText(TE2);
doc2.setHtml(TE2);
dialog->setWindowTitle(tr("Print Document"));
doc2.print(&printer);
qDebug()<<&printer;