我有一个应用程序,该应用程序应该在3台打印机中打印纸张,其中一台是本地打印机,另外2台是从服务器共享的,本地打印机是好的,但是对于打印到共享打印机,我在Win 10中有问题,我应该选择其中一种它们作为默认打印机进行打印。因此第二台共享打印机不打印,因为它不是默认打印机。我使用以下命令:
QString Services::print(QVariant data , int id){
QString mess="ss";
QImage img = qvariant_cast<QImage>(data);
QPrinter printer_(QPrinter::HighResolution);
QStringList name;
name=readSettings();
if(name.at(id)==""){
return "please enter the printer name ";
}
else{
printer_.setPrinterName(name.at(id));
printer_.setResolution(300);
printer_.setCopyCount(1);
printer_.setDoubleSidedPrinting(false);
printer_.setDuplex(QPrinter::DuplexNone);
printer_.setColorMode(QPrinter::Color);
printer_.setPageSize(QPrinter::A5);
printer_.setPaperSource(QPrinter::Auto);
printer_.setCreator("serverApp");
printer_.setOrientation(QPrinter::Portrait);
printer_.setDocName("factor");
printer_.setOutputFormat(QPrinter::NativeFormat);
if (!printer_.isValid())
return "printer not valid";
QPainter painter(&printer_);
QImage img2 =img.scaled(img.width()*1.65,img.height()*1.7);
painter.drawImage(QPoint(0,0),img2);
qDebug()<<printer_.printerState();
switch(printer_.printerState()){
case QPrinter::Idle:
mess="don't send";
break;
case QPrinter::Active:
mess="send";
break;
case QPrinter::Aborted:
mess="cancell";
break;
case QPrinter::Error:
mess="error";
break;
}
painter.end();
return mess;
}}
换句话说,有什么方法可以在Qt中设置默认打印机吗?
答案 0 :(得分:0)
我找出了问题所在,对于非默认的共享打印机,我们应该这样设置打印机名称:“ \\计算机服务器名称\服务器中的真实打印机名称”