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. In the constructor of my window I create my QPrinter:
mpPrinter = new QPrinter( );
To copy to clipboard, switch view to plain text mode
Inside my print( ) function my code looks like this in which mpPlot is my QGLWidget:
raise( );
QPrinterDialog printDialog( mpPrinter, this );
if( printDialog.exec( ) )
{
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( ) );
}
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( ) );
}
To copy to clipboard, switch view to plain text mode
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!
Bookmarks