Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QT Printing via CUPS

QT Printing via CUPS

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 2 Posters 174 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    Mahadev
    wrote on last edited by
    #1

    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.

    JonBJ 1 Reply Last reply
    0
    • M Mahadev

      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.

      JonBJ Offline
      JonBJ Offline
      JonB
      wrote on last edited by
      #2

      @Mahadev
      Maybe you should start by seeing whether you can print anything (e.g. "Hello World") to that printer from Qt? And also from outside Qt if you have not tried that.

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved