Results 1 to 1 of 1

Thread: QPainter problem with real printer on linux

  1. #1
    Join Date
    Feb 2012
    Qt products
    Unix/X11 Windows

    Default QPainter problem with real printer on linux

    I want to print line and text on a real printer but this doesn't work all the time, but on fake printer(screen, PDF and PS) this work.

    Qt Code:
    1. MainWindow::MainWindow(QWidget *parent)
    2. : QMainWindow(parent){
    3. QPushButton *b = new QPushButton("Print", this);
    4. setCentralWidget(b);
    5. connect(b, SIGNAL(clicked()), this, SLOT(onPrint()));
    6. }
    8. void
    9. MainWindow::onPrint(){
    10. QPrintDialog dialog(&p, this);
    11. if(dialog.exec() == QDialog::Accepted){
    12. QPainter *painter = new QPainter(&p);
    13. painter->drawLine(0,0,0,100);
    14. delete painter;
    15. }
    16. }
    To copy to clipboard, switch view to plain text mode 

    This piece of code doesn't work all time, sometimes CUPS tell me that job is cancelled, sometimes a line is draw.
    Is that someone already had this problem?

    If I put "sleep(1);" before delete painter this piece of code works. Complex printing (SvgRenderer and QTextDocument) works too.

    -Archlinux up-date
    -Qt 4.8.0
    -Cups 1.5.0 usblp
    Last edited by corossig; 22nd February 2012 at 14:55.

Similar Threads

  1. Replies: 6
    Last Post: 22nd November 2016, 13:57
  2. POS printer suitable on linux
    By Alir3z4 in forum General Discussion
    Replies: 5
    Last Post: 3rd August 2011, 11:30
  3. printer problem
    By arashadsaifi in forum Qt for Embedded and Mobile
    Replies: 3
    Last Post: 18th May 2011, 15:59
  4. Replies: 5
    Last Post: 7th September 2009, 20:57
  5. Replies: 4
    Last Post: 18th December 2007, 08:31

Tags for this Thread


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.