View Full Version : Save Printer Page Settings to show on next print

6th August 2012, 15:59
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

objVar= m_settings.value("PrinterSettings", m_printer);
m_printer = objVar.value<QPrinter>();

m_settings.setValue("PrinterSettings", m_printer);

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

6th August 2012, 23:16
You must retrieve each of the page settings you are interested in and save them individually:

QSettings settings( "MyOrg", "MyApp" );
settings.setValue( "PaperSize", m_printer.paperSize() );
settings.setValue( "ColorMode", m_printer.colorMode() );
// etc.

m_printer.setPaperSize( QPrinter::PaperSize( settings.value( "PaperSize" ).toInt() ) );
m_printer.setColorMode( QPrinter::ColorMode( settings.value( "ColorMode" ).toInt() ) );
// etc.

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.