Results 1 to 2 of 2

Thread: Save Printer Page Settings to show on next print

  1. #1
    Join Date
    Jul 2012
    Location
    India
    Posts
    33
    Thanks
    10
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Save Printer Page Settings to show on next print

    I am trying to save a page settings of a printer for future use in my application

    I tried this bot not worked because m_printer is not a variant type its the object QPrinter
    Qt Code:
    1. objVar= m_settings.value("PrinterSettings", m_printer);
    2. m_printer = objVar.value<QPrinter>();
    To copy to clipboard, switch view to plain text mode 

    Qt Code:
    1. m_settings.setValue("PrinterSettings", m_printer);
    To copy to clipboard, switch view to plain text mode 



    How to save printer settings and re asign to next time use

  2. #2
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,230
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Save Printer Page Settings to show on next print

    You must retrieve each of the page settings you are interested in and save them individually:

    Qt Code:
    1. QSettings settings( "MyOrg", "MyApp" );
    2. settings.setValue( "PaperSize", m_printer.paperSize() );
    3. settings.setValue( "ColorMode", m_printer.colorMode() );
    4. // etc.
    5.  
    6. m_printer.setPaperSize( QPrinter::PaperSize( settings.value( "PaperSize" ).toInt() ) );
    7. m_printer.setColorMode( QPrinter::ColorMode( settings.value( "ColorMode" ).toInt() ) );
    8. // etc.
    To copy to clipboard, switch view to plain text mode 

    Basically, you can't convert a QPrinter instance into a QVariant for use in setValue(). So, you must store each setting separately, with type conversions as appropriate.
    <=== The Great Pumpkin says ===>
    Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.

Similar Threads

  1. How to print text file to printer ?
    By d_stranz in forum Qt Programming
    Replies: 5
    Last Post: 11th July 2012, 16:47
  2. How to print pdf file on Printer in windows
    By lekhrajdeshmukh in forum Qt Programming
    Replies: 9
    Last Post: 30th November 2011, 16:36
  3. Replies: 1
    Last Post: 9th November 2009, 09:27
  4. How to print textDocument on virtual printer?
    By mSergey in forum Qt Programming
    Replies: 8
    Last Post: 17th January 2008, 13:49
  5. Replies: 4
    Last Post: 18th December 2007, 08:31

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.