Results 1 to 4 of 4

Thread: printer problem

  1. #1
    Join Date
    Dec 2009
    Posts
    8
    Thanked 1 Time in 1 Post
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11

    Default printer problem

    Hi All,

    I am using qt-embedded-4.5 on linux and qt 4.5 on window.
    I have written the following code for printing on window and embedded linux (kernel 2.6.27).
    Following code is not able to detect the printer on Linux but it is working on windows.

    And I have tested printer manualy on Linux
    like
    USB printer is detected in directory /dev/usb/lp0.

    using cat/echo command it is possible to print the file and text.
    cat file > /dev/usb/lp0



    What could be the problem?

    Thanks for giving your valuable time.


    QPrinter printer;
    QPrintDialog dlg( &printer );
    if( dlg.exec() == QDialog::Accepted )
    {
    QPainter painter( &printer );

    painter.setPen( Qt::black );

    for( int page=0; page<5; page++ )
    {
    painter.drawRect( printer.pageRect() );
    painter.drawLine( printer.pageRect().topLeft(), printer.pageRect().bottomRight() );
    painter.drawLine( printer.pageRect().topRight(), printer.pageRect().bottomLeft() );

    QRectF textArea(
    printer.pageRect().left() +printer.resolution() * 0.5,
    printer.pageRect().top() +printer.resolution() * 0.5,
    printer.pageRect().width() -printer.resolution() * 1.0,
    printer.pageRect().height()-printer.resolution() * 1.5 );

    painter.drawRect( textArea );

    painter.drawText( textArea, Qt::AlignTop | Qt::AlignLeft, QString( "Page %1" ).arg( page+1 ) );

    if( page != 4 )
    printer.newPage();
    }
    }

  2. #2
    Join Date
    Jan 2006
    Location
    Frankfurt
    Posts
    500
    Thanks
    1
    Thanked 52 Times in 52 Posts
    Platforms
    MacOS X Unix/X11

    Default Re: printer problem

    Does it work with other Qt applications, for example the textedit-example from the Qt distribution?
    It's nice to be important but it's more important to be nice.

  3. #3
    Join Date
    Dec 2009
    Posts
    8
    Thanked 1 Time in 1 Post
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11

    Default Re: printer problem

    Thanks for your reply.

    yes it is working for textedit-example also

  4. #4
    Join Date
    Feb 2011
    Posts
    2
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: printer problem

    Hi arashadsaifi
    Have you solved the problem, please?
    I have the same problem. My linux embedded system detects the USB printer at usblp0, but in the QPrintDialog not display it, only list "Print to file/PDF)" and "Print to file (Postscript).

    Thanks
    Joan

Similar Threads

  1. Very strange socket programming problem
    By montylee in forum Qt Programming
    Replies: 5
    Last Post: 11th November 2008, 12:05
  2. deployment problem: msvc++ 2008 Express, Qt 4.4.3
    By vonCZ in forum Qt Programming
    Replies: 7
    Last Post: 10th November 2008, 14:38
  3. Problem in using QHttp with QTimer
    By Ferdous in forum Newbie
    Replies: 2
    Last Post: 6th September 2008, 12:48
  4. Grid Layout Problem
    By Seema Rao in forum Qt Programming
    Replies: 2
    Last Post: 4th May 2006, 12:45
  5. fftw problem
    By lordy in forum General Programming
    Replies: 1
    Last Post: 16th March 2006, 21:36

Tags for this Thread

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.