Results 1 to 4 of 4

Thread: printing a(n existing) file in Qt

  1. #1
    Join Date
    Dec 2006
    Posts
    849
    Thanks
    6
    Thanked 163 Times in 151 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default printing a(n existing) file in Qt

    I have a file that I'd like to print.
    Is it possible (a good idea?) to use QPrintDialog/QPrinter for that?
    When I do
    Qt Code:
    1. QPrintDialog dialog(&printer, myDialog);
    2. if (dialog.exec()) {
    3. // now I got a printer, but how to print the file...?
    4. qDebug() << "how to print to" << printer.printerName();
    5. }
    To copy to clipboard, switch view to plain text mode 
    I'd rather not just call "lpr -PMYPRINTER MYFILE" (ugly).

    Moreover, the QPrintDialog allows the user to specify the number of copies etc.
    If I don't print via QPrinter, how could/should I make an external viewer use those settings?


    So, my question boils down to:
    • can I print a file with Qt? (i.e. use Qt's printer selection, and have Qt send my file via 'the appropriate channels' to that printer; assuming the printer does understand the file type)
    • (I do not want to implement the drawing itself!),
    • or do I have to use an external program for that?



    (I'd like to avoid calling something platform dependent, otherwise I might just call KDE's kprinter.)

    Christoph

  2. #2
    Join Date
    Dec 2006
    Posts
    849
    Thanks
    6
    Thanked 163 Times in 151 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: printing a(n existing) file in Qt

    anyone got an idea? please?

  3. #3
    Join Date
    Oct 2006
    Location
    New Delhi, India
    Posts
    2,467
    Thanks
    8
    Thanked 334 Times in 317 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: printing a(n existing) file in Qt

    Whats the harm in using QPrinter ??
    Also you can have a look at QPrinter::setPrintProgram if u are using X11
    See also - QWidget::render

  4. #4
    Join Date
    Dec 2006
    Posts
    849
    Thanks
    6
    Thanked 163 Times in 151 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: printing a(n existing) file in Qt

    Hi aamer4yu. Thank you.

    The harm is as follows:
    * QPrinter lets the user configure stuff; if I use a custom external program, I would want those options passed on and understood
    * (I am on X11; would prefer non-platform spec. stuff though) QPrinter::setPrintProgram() can indeed be used; however it does not solve the painting part (I still have to paint myself). It only changes the printing backend.
    * QWidget::render is no real help; I do not want to render stuff myself. I have a defined set of files (ASCII, PostScript, PDF) that I would like to be printed. I have no desire to implement rendering those myself. (Although I already did that once for postscript.)

    What I would like is the possibility to pass an existing (e.g.) postscript file to QPrinter and just use its configuration capabilites.

Similar Threads

  1. Set up the Qt4.3.2 with Visual Studio 2005
    By lamoda in forum Installation and Deployment
    Replies: 6
    Last Post: 30th January 2008, 06:51
  2. file renaming on windows
    By jdd81 in forum Qt Programming
    Replies: 9
    Last Post: 2nd October 2007, 19:41
  3. qt-3.3.8 fail in scratchbox
    By nass in forum Installation and Deployment
    Replies: 0
    Last Post: 25th May 2007, 15:21
  4. Sending Binary File with QFTP
    By nbkhwjm in forum Newbie
    Replies: 2
    Last Post: 7th March 2007, 18:10
  5. Printing a PRN file on an NDPS printer
    By janca in forum General Discussion
    Replies: 4
    Last Post: 20th March 2006, 22:11

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.