View Full Version : QPrinter does not print anything

22nd August 2006, 19:34
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,

void MainWindow::printScore()
if (!printer)
printer = new QPrinter;
printer->setPrintProgram("lpr"); // without this line no print!
QPrintDialog printDialog(printer, this);
if (printDialog.exec() == QDialog::Accepted)
QPainter pp(printer);
pp.setPen(QPen(QColor(100, 100, 100)));
pp.drawLine( 10, 10, 100, 100 );