QT Printing via CUPS
-
Hi,
I had to configure the Postek label printer Model (C168/200+) on the Raspberry Pi via a cable connection and then set up the printer in CUPS.
I made a project to print an image to a printer, but the picture that was uploaded to the queue didn't print.
this is my code ,
QPixmap image("E:/My Project files/img.png"); QPrinter *printer = new QPrinter(QPrinter::HighResolution); printer->setPrinterName("POSTEK_C168_200"); printer->setPaperSize(QSizeF(2.36, 0.98), QPrinter::Inch); printer->setFullPage(true); QPainter painter; painter.begin(printer); // Calculate scale factor double xscale = printer->pageRect().width() / double(image.width()); double yscale = printer->pageRect().height() / double(image.height()); double scale = qMin(xscale, yscale); // Center the image on the label painter.translate(printer->paperRect().x() + printer->pageRect().width() / 2, printer->paperRect().y() + printer->pageRect().height() / 2); painter.scale(scale, scale); painter.translate(-image.width() / 2, -image.height() / 2 -10); painter.drawPixmap(0, 0, image); painter.end(); ui->label_39->render(&painter);
The code works on Windows Qt, but not in Raspberry Pi Qt. When I hit the print button, the printer media LED blinks once but does not print anything.
how to solve the issue,the printers listed in the picture
Thanks. -
Hi,
I had to configure the Postek label printer Model (C168/200+) on the Raspberry Pi via a cable connection and then set up the printer in CUPS.
I made a project to print an image to a printer, but the picture that was uploaded to the queue didn't print.
this is my code ,
QPixmap image("E:/My Project files/img.png"); QPrinter *printer = new QPrinter(QPrinter::HighResolution); printer->setPrinterName("POSTEK_C168_200"); printer->setPaperSize(QSizeF(2.36, 0.98), QPrinter::Inch); printer->setFullPage(true); QPainter painter; painter.begin(printer); // Calculate scale factor double xscale = printer->pageRect().width() / double(image.width()); double yscale = printer->pageRect().height() / double(image.height()); double scale = qMin(xscale, yscale); // Center the image on the label painter.translate(printer->paperRect().x() + printer->pageRect().width() / 2, printer->paperRect().y() + printer->pageRect().height() / 2); painter.scale(scale, scale); painter.translate(-image.width() / 2, -image.height() / 2 -10); painter.drawPixmap(0, 0, image); painter.end(); ui->label_39->render(&painter);
The code works on Windows Qt, but not in Raspberry Pi Qt. When I hit the print button, the printer media LED blinks once but does not print anything.
how to solve the issue,the printers listed in the picture
Thanks.