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

In Windows, QPrinter::isValid returns false for remote shared printers that aren't declared locally

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Out of scope
    • Icon: P3: Somewhat important P3: Somewhat important
    • 4.8.x
    • 4.6.1
    • GUI: Printing
    • None
    • Windows XP SP3, Visual Studio 2005

      Consider this :

      QPrinter printer;
      printer.setPrinterName("\\\\Server
      SharedPrinter");
      bool b1 = printer.isValid();

      QPainter painter;
      bool b2 = painter.begin(&printer);

      If the remote printer isn't declared in the local list of printers, printer.isValid() returns false. Yet painter.begin() returns true, and printing works correctly.

      If this is intended behavior, maybe the documentation for QPrinter::isValid() should mention that it only works with local printers. And also that a false return value doesn't necessarily mean that printing will fail.

      As we can't rely on QPrinter::isValid(), in the windows version of our software, we replaced it by a custom function that calls Win32's OpenPrinter() and GetPrinter() to really check if the printer exists. But this solution might be a little heavy for QPrinter::isValid().

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

            johnlayt John Layt
            jcugniere Julien Cugnière
            Votes:
            2 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved:

                There are no open Gerrit changes