简体   繁体   English

Qt:在打印机点矩阵上打印

[英]Qt: printing on printer dot matrix

I'm trying to print some string to a printer dot matrix LX-300+ using Qt but it seems that the font is skewed. 我正在尝试使用Qt将一些字符串打印到打印机点阵LX-300 +,但字体似乎偏斜。 Some users also have this problem http://www.qtcentre.org/threads/11814-printing-program-in-LX-300-(dot-matrix-printer)-problem but i can't find the solutions until now. 一些用户也有此问题http://www.qtcentre.org/threads/11814-printing-program-in-LX-300-(dot-matrix-printer)-问题,但直到现在我都找不到解决方案。 Please help me to address this problem. 请帮助我解决这个问题。 Do i need to create a dll or application using other framework maybe .net if this is Qt bug? 如果这是Qt错误,我是否需要使用其他框架(例如.net)创建dll或应用程序? Here is my code 这是我的代码

QTextDocument document;
QTextCursor cursor = QTextCursor(&document);
QFont font = QFont("Courier");
QTextCharFormat format = QTextCharFormat();
format.setFont(font);
cursor.setCharFormat(format);
cursor.insertText("lorem ipsum dolor sit amit amit ");

QPrinter printer(QPrinter::ScreenResolution);
printer.setPrinterName(ui->ddlPrinter->currentData().toString());
printer.setColorMode(QPrinter::GrayScale);
printer.setPageSize(QPrinter::A4);
printer.setFullPage(false);
QPrintDialog dialog(&printer, this);
document.print(&printer);

i'm using Qt5.4.0 mingw491 32 OS win 7 64bit 我正在使用Qt5.4.0 mingw491 32 OS win 7 64bit

I can solve this problem using Windows API directly like this pseudo code 我可以像下面的伪代码一样直接使用Windows API解决此问题

OpenPrinter(name,&hPrinter, NULL);
dwJob = StartDocPrinter( hPrinter, 1, (LPBYTE)&DocInfo );
bStatus = StartPagePrinter(hPrinter);
BOOL bStatus = WritePrinter(hPrinter,(LPVOID)buffer,text.length(),&dwBytesWritten);

hope this help someone 希望这可以帮助某人

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM