PDA

View Full Version : QPrinter on Solaris



ToddAtWSU
11th October 2006, 21:49
I am trying to print a QGLWidget I have displayed inside a window. I am running on a Solaris machine and just want to use lp to print out my image. I used this same code on another network using a LINUX box and it worked just fine. But on Solaris I do not see any printer choices inside my QPrinterDialog. :confused: In the constructor of my window I create my QPrinter:


mpPrinter = new QPrinter( );

Inside my print( ) function my code looks like this in which mpPlot is my QGLWidget:


raise( );
QPixmap imageToPrint = QPixmap::grabWindow( mpPlot->winId( ) );

QPrinterDialog printDialog( mpPrinter, this );

if( printDialog.exec( ) )
{
QPainter painter( mpPrinter );
QRect = painter.viewport( );
QSize size = imageToPrint.size( );

size.scale( rect.size( ), Qt::KeepAspectRatio );
painter.setViewport( rect.x( ), rect.y( ), size.width( ), size.height( ) );
painter.setWindow( imageToPrint.rect( ) );
painter.drawImage( 0, 0, imageToPrint.toImage( ) );
}

As I said, this exact code works on a LINUX box but not on my Solaris box on another network. I was able to print in Nedit in Solaris so I know the lp is connected and working with my Solaris machine. Does anybody have any idea how to get my QPrinterDialog to recongnize a printer is hooked up to the machine through the network? Is it possible to even get this to work without using the QPrintDialog? I would prefer to do it this way but if I cannot, as long as I can print my image to the printer, that should be acceptable. Thanks for your help!

wysota
13th October 2006, 20:48
Are you by any chance using Qt4.2? You probably have CUPS installed on your Linux box and you don't have it installed on Solaris.

ToddAtWSU
17th October 2006, 13:18
I am using Qt 4.1.4. We are in the process of updating to 4.2 but have yet to test integration to the newest version. Was something fixed for printer dialogs in 4.2? Should I install CUPS on the Solaris systems if I don't have it? I read something about CUPS elsewhere but really have no idea what it is. Thanks again for your help!

wysota
17th October 2006, 14:22
I think CUPS is responsible for listing the printers. I thought support for it was added in Qt4.2, but I'm not sure. If you want to choose a printer, you need some mechanism which will give you something to choose from. You might simply be missing it on Solaris (be it CUPS or anything else).

ToddAtWSU
24th October 2006, 20:29
It looks like I just can't use the QPrinterDialog to print to the printer. If I take out my call to the QPrinterDialog and set my program to be "lp" it prints to the printer. Unfortunately in my new post I explain how I am not getting what I want to print, but at least I can send something to the printer. I will just have to make up my own printing dialog for this program to work on the Solaris network. Thanks again!