我正在开发一个程序来管理库存并通过Qt进行销售,我正在尝试打印销售收据,但仅从几乎一半的纸张开始打印
settings.beginGroup("Geral");
QString nomeEmpresa = settings.value("nomeEmpresa").toString();
QString cnpj = settings.value("cnpj").toString();
settings.endGroup();
QString content = "<b>" + nomeEmpresa + "</b><br/>" + cnpj + "<br/>"
"<br/><hr style='border: 1px solid #000000;'/>"
"<br/><table><thead><tr><th>Quantidade</th><th>Produto</th></tr></thead>"
"<tbody>";
for(int i = 0; i < items.size(); i++){
content.append("<tr><td>" + QString::number(items.value(i).quantidade) + "</td><td>" + items.value(i).produto.codigoVenda() + "</td></tr>");
}
content.append("</tbody></table><br/><br/><br/><b>Obrigado pela preferência. Volte sempre</b>");
//QString content = "Teste de alinhamento da impressao";
QTextDocument doc;
doc.setHtml(content);
QPrinter printer;
printer.setResolution(QPrinter::HighResolution);
printer.setOutputFormat(QPrinter::NativeFormat);
printer.setOrientation(QPrinter::Portrait);
QPrintDialog dlgImpressao(&printer);
if(dlgImpressao.exec() == QPrintDialog::Accepted){
doc.print(&printer);
}
左侧是我所在城市的超级市场的收据,右侧是正在打印的收据Qt
我希望它的打印方式与左侧示例相同,但没有任何进展