Results 1 to 5 of 5

Thread: QPrinter on Solaris

  1. #1
    Join Date
    Jan 2006
    Location
    Ohio
    Posts
    332
    Thanks
    37
    Thanked 8 Times in 4 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Unhappy QPrinter on Solaris

    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:

    Qt Code:
    1. 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:

    Qt Code:
    1. raise( );
    2. QPixmap imageToPrint = QPixmap::grabWindow( mpPlot->winId( ) );
    3.  
    4. QPrinterDialog printDialog( mpPrinter, this );
    5.  
    6. if( printDialog.exec( ) )
    7. {
    8. QPainter painter( mpPrinter );
    9. QRect = painter.viewport( );
    10. QSize size = imageToPrint.size( );
    11.  
    12. size.scale( rect.size( ), Qt::KeepAspectRatio );
    13. painter.setViewport( rect.x( ), rect.y( ), size.width( ), size.height( ) );
    14. painter.setWindow( imageToPrint.rect( ) );
    15. painter.drawImage( 0, 0, imageToPrint.toImage( ) );
    16. }
    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!

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QPrinter on Solaris

    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.

  3. #3
    Join Date
    Jan 2006
    Location
    Ohio
    Posts
    332
    Thanks
    37
    Thanked 8 Times in 4 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Wink Re: QPrinter on Solaris

    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!

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QPrinter on Solaris

    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).

  5. #5
    Join Date
    Jan 2006
    Location
    Ohio
    Posts
    332
    Thanks
    37
    Thanked 8 Times in 4 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: QPrinter on Solaris

    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!

Similar Threads

  1. Replies: 2
    Last Post: 31st August 2011, 16:15
  2. 4.1.0 qmake compiler error - Solaris
    By Novahokie in forum Installation and Deployment
    Replies: 6
    Last Post: 19th April 2007, 18:49
  3. QT 4.1.1 on Solaris 10
    By KaptainKarl in forum Installation and Deployment
    Replies: 1
    Last Post: 7th February 2007, 13:51
  4. How to use QPrinter without QPrintDialog?
    By pascal456 in forum Qt Programming
    Replies: 2
    Last Post: 15th November 2006, 19:57
  5. Installing on Solaris...PLEASE HELP!
    By Rayven in forum Installation and Deployment
    Replies: 3
    Last Post: 27th July 2006, 17:33

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.