+ Reply to Thread
Results 1 to 8 of 8

Thread: Printer problem

  1. #1
    Join Date
    Nov 2012
    Location
    Kentucky, USA
    Posts
    46
    Thanks
    21
    Qt products
    Qt4
    Platforms
    Windows

    Default Printer problem

    Running Qt under Windows and for some reason it can't find the printers (there are 7 including both network and usb printers).

    Here's the relevant code:
    Qt Code:
    1. QT += sql \
    2. printsupport \
    3. serialport \
    4. xml \
    5. network \
    6. widgets
    7.  
    8.  
    9. from mainwindow.h
    10. #include <QPrinter>
    11. #include <QPrintDialog>
    12. #include <QPrinterInfo>
    13.  
    14. from mainwindow.cpp
    15. QList <QPrinterInfo> plist = QPrinterInfo::availablePrinters();
    16. qDebug() << "len = " << plist.length(); // len comes back zero
    17.  
    18. QPrinter printer;
    19. printer.setPrinterName("DYMO LabelWriter 450");
    20. qDebug() << "printer valid? " << printer.isValid(); // comes back false
    To copy to clipboard, switch view to plain text mode 

    I have another application that uses the same code and it reports 7 printers and prints to the Dymo just fine.
    Any idea what I am missing here?

  2. #2
    Join Date
    Sep 2006
    Posts
    38
    Thanks
    5
    Thanked 3 Times in 2 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Windows

    Default Re: Printer problem

    What happens if you use a PrintDialog instead? Something like
    Qt Code:
    1. QPrintDialog dialog(printer, this);
    2. if (dialog.exec() == QDialog::Rejected) {
    3. return;
    4. }
    To copy to clipboard, switch view to plain text mode 
    Does it show a list of printers attached to the computer?

  3. #3
    Join Date
    Nov 2012
    Location
    Kentucky, USA
    Posts
    46
    Thanks
    21
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Printer problem

    QPrintDialog returns: QPrintDialog: Cannot be used on non-native printers
    Because no printers are found.

  4. #4
    Join Date
    Dec 2007
    Location
    London
    Posts
    203
    Thanks
    40
    Qt products
    Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android

    Default Re: Printer problem

    I also have the same problem. On my development machine(Win7 64 Bit, Qt 5.2 mingw) it works. But when i deploy the application to another computer i get the warning:

    QPrintDialog: Cannot be used on non-native printers

    I tried it with WinXP on virtualbox, again the problem exists. plugins\printsupport\windowsprintersupport.dll and platform\qwindows.dll exists in binary folder.

    Any idea ?

  5. #5
    Join Date
    Nov 2012
    Location
    Kentucky, USA
    Posts
    46
    Thanks
    21
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Printer problem

    Sorry Yagabey, no idea. Also running under Win 7/64. I have 2 applications. Both use the same code. It works on one but not the other. The one that does not work returns a list of zero printers from QList <QPrinterInfo> plist = QPrinterInfo::availablePrinters();
    And print dialog gives me the same error message that you get.

  6. #6
    Join Date
    Feb 2014
    Posts
    1
    Thanked 1 Time in 1 Post
    Qt products
    Qt4 Qt5
    Platforms
    Windows

    Default Re: Printer problem

    Hi guys! I had the same problem and the reason was I put the wrong "windowsprintersupport.dll" in "plugins\printsupport\" dir. There were two different dll files in my Qt dir. You should take the right one.

  7. The following user says thank you to Ritchie for this useful post:

    nils_heidorn (19th March 2015)

  8. #7
    Join Date
    Oct 2010
    Posts
    7
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Printer problem

    QPrintDialog can't be used with pdfs on Windows because it is a native print dialog and has no knowledge of Qt's PDF printer.

  9. #8
    Join Date
    Apr 2015
    Location
    Sydney
    Posts
    9
    Qt products
    Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Printer problem

    I have the same problem...
    I changed the line
    printer.setOutputFileName("Filename.pdf");
    to
    printer.setOutputFileName("Filename");
    and the printdialog worked.
    I made sure the print to file was not ticked...and whalla...(ozzie slang for great it worked)
    a print of what I wanted worked.

    Thanks for the Help to all

+ Reply to Thread

Similar Threads

  1. Replies: 6
    Last Post: 22nd November 2016, 14:57
  2. QPainter problem with real printer on linux
    By corossig in forum Qt Programming
    Replies: 0
    Last Post: 22nd February 2012, 15:47
  3. printer problem
    By arashadsaifi in forum Qt for Embedded and Mobile
    Replies: 3
    Last Post: 18th May 2011, 16:59
  4. Getting Printer Status...
    By aalekhm in forum Qt Programming
    Replies: 0
    Last Post: 26th October 2009, 06:34
  5. No printer installed..?
    By Cutey in forum Qt Programming
    Replies: 2
    Last Post: 24th February 2007, 12:08

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts