Results 1 to 1 of 1

Thread: QPrinter does not print anything

  1. #1
    Join Date
    Aug 2006
    Posts
    3
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default QPrinter does not print anything

    Hi all,
    is the first time I use QPrinter, what I want is a simple print test using QPrintDialog to setup printer properties (my qt version is 4.2 and CUPS as printing system).
    The problem is that after press 'Print' button in the setup dialog nothing happen and printer queue are always empty. It works only if print program (like lpr) is set with printer->setPrintProgram("lpr"). I'm confused about this because I supposed that print program was automatically defined by printing system... but it seems not.
    In Kde application I can print with no problem.
    Thanks to all for suggestion,
    Marco

    Qt Code:
    1. void MainWindow::printScore()
    2. {
    3. if (!printer)
    4. printer = new QPrinter;
    5. printer->setPrintProgram("lpr"); // without this line no print!
    6. QPrintDialog printDialog(printer, this);
    7. if (printDialog.exec() == QDialog::Accepted)
    8. {
    9. QPainter pp(printer);
    10. pp.setPen(QPen(QColor(100, 100, 100)));
    11. pp.drawLine( 10, 10, 100, 100 );
    12. pp.end();
    13. }
    14. }
    To copy to clipboard, switch view to plain text mode 
    Last edited by jacek; 22nd August 2006 at 19:48. Reason: added code tags

Similar Threads

  1. Replies: 2
    Last Post: 31st August 2011, 16:15
  2. how to print an html file?
    By patcito in forum Qt Programming
    Replies: 5
    Last Post: 31st August 2008, 16:50
  3. How to use QPrinter without QPrintDialog?
    By pascal456 in forum Qt Programming
    Replies: 2
    Last Post: 15th November 2006, 19:57
  4. [QT4] QThread and printing a QList<QPixmap>
    By KShots in forum Qt Programming
    Replies: 3
    Last Post: 24th April 2006, 21:44
  5. [SOLVED] Print to pdf
    By Morea in forum Newbie
    Replies: 10
    Last Post: 8th April 2006, 10:12

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
  •  
Qt is a trademark of The Qt Company.