qt - Receipt printer feeds paper instead of printing text -


i working on test application printing in ubuntu 14.04.3 lts cups 1.7.2 , qt 5.5.1 opensource 64bit. i've added printer driver in cups , test page printed ok. now, app consists of qtextedit , qpushbutton, pressed() signal triggers following slot:

void uecentralwidget::uesendtexttoprinter() { //    qstringlist availableprintersnames=qprinterinfo::availableprinternames();  //    for(int indexprintername=0; indexprintername<availableprintersnames.size(); indexprintername++) //    { //        qdebug() << q_func_info //                 << availableprintersnames.at(indexprintername); //    }   //     qdebug() << q_func_info              << "text print: "              << this->ueprintertexteditor()->document()->toplaintext();      qlist<qprinterinfo> availableprinters=qprinterinfo::availableprinters();      for(int indexprinter=0; indexprinter<availableprinters.size(); indexprinter++)     { //        qdebug() << q_func_info //                 << availableprinters.at(indexprinter).makeandmodel();          if(availableprinters.at(indexprinter).makeandmodel().contains("pos58"))         {             qdebug() << q_func_info                      << "printer found";              qprinter printer(availableprinters.at(indexprinter));              qdebug() << q_func_info                      << printer.pagelayout().fullrect();              qpainter printerpainter(&printer);              qdebug() << q_func_info                      << printerpainter.fontinfo().family()                      << printerpainter.fontinfo().pixelsize()                      << printerpainter.fontinfo().pointsize();              if(printerpainter.begin(&printer))             {                 printerpainter.drawtext(100,                                         100,                                         this->ueprintertexteditor()->document()->toplaintext());             }              printerpainter.end();         }   // if     }   // } 

when slot executes, printer job added cups queue, means printer found, however, printer feeds printer , no text printed. still missing?

you don't need printerpainter.begin(&printer) or printerpainter.end().

i don't know why fixes you, if guess might because explicitly calling printerpainter.end() prematurely completes paint operation before drawing done.


Comments