Getting the page sizes to UI: QPrinterInfo printer = QPrinterInfo::printerInfo() įor (auto x=0 xplistSizeBox->addItem(printer.supportedPageSizes().at(x). I removed all error checking and nonessential code. The UI had a combo box (named pListSizeBox) that had available paper sizes listed, user had to select the file, paper size (for many reasons this could not be the actual dimensions of the PDF file) and click on button.Īctual image was in a handy QImage named label. You want to print text, so instead of my drawImage() it would be drawText() for you (I find this part really tricky to implement as one needs to be careful about positioning the data for drawing - I printed mostly 4"圆" and 4"x2.5"). The case, as I mentioned, was different (I used Poppler library to render PDF files to bitmap, later on on Mac I switched to QtPDF but that is not relevant here). This code is ancient but the principles are there. If your printer is not there it means the system can't see it properly and usual Qt routines will managed to find a copy of the routines I used years ago to deal with Zebra. Default and all page size are in the relevant QPrinterInfo object.īut first thing to try is to check if Qt sees your printer by checking return values from availablePrinterNames(). You also might need to setup page size before calling painter.begin() but I think default should work. Label printers are also available to rent from UPS by calling the UPS Customer Service Center at 18007425877. Label printers are available for purchase through the UPS Digital Connections Program for qualified customers (US only). QPrinter *printer = new QPrinter(printerInfo,QPrinter::HighResolution) UPS-provided printer drivers for Bixolon and Zebra can be found below. QPrinterInfo printerInfo = QPrinterInfo::printerInfo(printers.at(0)) Code that should work: QStringList printers = QPrinterInfo::availablePrinterNames() Having checked that, let's assume that your printer is listed as the first one. You do QPrinterInfo::availablePrinterNames() (can be sent to qDebug()) - do you see the name of your Zebra? You should initialise the printer with exactly that name (I always copy it from relevant position in QStringList returned by availablePrinterNames()).
0 Comments
Leave a Reply. |