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. QPageLayout gives result from wrong printer

QPageLayout gives result from wrong printer

Scheduled Pinned Locked Moved Unsolved General and Desktop
1 Posts 1 Posters 61 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
    MartinGU
    wrote on last edited by
    #1

    QT 6.10
    Linux Mint 22.2

    Trying to use QPageLayout to get info about selected printer but it returns a paper size
    that does not exist in the printer driver. Somehow it must get info from the wrong printer driver?

    I have a special printer ppd for a 80MM label printer, it contains ONE (1) paper type called 80MM.
    If I print from other applications or use QPrintDialog it print 80MM wide.

    However I want to set printer without dialog and get the correct paper name/sizes

    // Select printer and create QPrinter
    QPrinterInfo printerInfo = QPrinterInfo::printerInfo("PDF80");
    QPrinter *printer = new QPrinter(printerInfo, QPrinter::HighResolution);

    // Print printername from QPrinter (to check printer is selected)
    QString sPrinterName = printer->printerName();
    ui->listWidget->addItem("QPrinter/ Printer: " + sPrinterName); // Shows: PDF80

    // Get list of supported page sizes (ppd has only one)
    QList ql = printerInfo.supportedPageSizes();
    QString name = ql[0].name();
    ui->listWidget->addItem("QPrinterInfo/ Paper: " + name); // Shows: 80MM

    // Create QPageLayout from printe rand get pagesize
    QPageLayout pl = printer->pageLayout();
    QString papersize = pl.pageSize().name();
    ui->listWidget->addItem("QPageLayout/ Paper: " + papersize); // Shows: A4

    /Martin

    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