Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-85262

Custom Printing(PageSize) is not working properly on QPrintPreviewDialog,QPrintDialog

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Reported
    • Priority: P3: Somewhat important
    • Resolution: Unresolved
    • Affects Version/s: 5.12.8, 5.15.0
    • Fix Version/s: None
    • Component/s: GUI: Printing
    • Labels:
      None
    • Platform/s:
      Linux/X11

      Description

      My OS version is Ubuntu 20.04

       

      I want to print with custom size as Half-Letter. I 've already loaded the printer by

      printer.setPaperSize( QSizeF(216,140) , QPrinter::Unit::Millimeter );

       

      By using QPrintPreviewDialog  to preview custom size ,it seems printing preview is valid.

      qDebug() << printer.pageSize(); // this return 30

      But after click  print button and print to printer ,the size is not valid.

      qDebug() << printer.pageSize(); // this return 0  on printing to printer

       

      Without using custom size ,it works fine. Only custom size will never work.

       

      I fixed my software by avoiding QPrintPreviewDialog
      and QPrintDialog

       

      //## it works without QPrintPreviewDialog
      and QPrintDialog .

      if ( printer.pageSize() == QPrinter::PageSize::Custom ) {

      QList<QPrinterInfo> list_printer=QPrinterInfo::availablePrinters();

      QStringList string_list_printer_name;
      for(int i=0;i<list_printer.size();++i)
      {
      QPrinterInfo printer_info=list_printer.at;
      string_list_printer_name << printer_info.printerName();
      }
      QInputDialog dialog_select_printer;

      dialog_select_printer.setOptions(QInputDialog::UseListViewForComboBoxItems);
      dialog_select_printer.setComboBoxItems(string_list_printer_name);
      dialog_select_printer.setWindowTitle("Select Printer");
      dialog_select_printer.exec();

      QString printer_name=dialog_select_printer.textValue();

      qDebug() << "select printer_name : " << printer_name;

      printer.setPrinterName( printer_name );

      QPainter painter;
      painter.begin(&printer);

      Render(painter);

      painter.end();

      {color:#00875a}}

       

       

        Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

            Assignee:
            johnlayt John Layt
            Reporter:
            pawaktanon Ukrid Pawaktanon
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Dates

              Created:
              Updated:

                Gerrit Reviews

                There are no open Gerrit changes