Results 1 to 1 of 1

Thread: QT and Dotmatrix printing

  1. #1
    Join Date
    Dec 2009
    Posts
    9
    Thanks
    1
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default QT and Dotmatrix printing

    Hi Everybody,
    I have built an application in Qt 3.3.4 and will generate a Report and should be printed using a Dot Matrix Printer directly from the application. Now we are doing this by generating the report in an excel format and the and save this file as a .csv file and then using a driver this csv file is processed and send this to the dot matrix printer through an applet and printing. but this will be very difficult for an end user. Expecting Ideas.....


    Here is Sample code for the text printing:

    while clicking a print button the signal will execute the following code:

    void RptPrintDlg:rintPayslip(){
    #ifndef QT_NO_PRINTER
    QPrinter printer;
    printer.setFullPage(TRUE);

    if ( printer.setup( this ) ) {

    QPainter p( &printer );
    QPaintDeviceMetrics metrics(p.device());

    int dpix = metrics.logicalDpiX();
    int dpiy = metrics.logicalDpiY();
    const int margin =20; // pt old Margin 72
    QRect body(margin*dpix/72, margin*dpiy/72,
    metrics.width()-margin*dpix/72*2,
    metrics.height()-margin*dpiy/72*2);

    QSimpleRichText richText( txeReport->text(), QFont(), txeReport->context(), txeReport->styleSheet(),
    txeReport->mimeSourceFactory(), body.height());

    richText.setWidth( &p, body.width());
    QRect view( body );
    int page = 1;
    do {
    richText.draw( &p, body.left(), body.top(), view, colorGroup() );
    view.moveBy( 0, body.height() );
    p.translate( 0 , -body.height() );
    p.drawText( view.right() - p.fontMetrics().width( QString::number(page) ),
    view.bottom() + p.fontMetrics().ascent() + 5, QString::number(page) );
    if ( view.top() >= richText.height() )
    break;
    printer.newPage();
    page++;
    } while (TRUE);
    }
    #endif

    }
    Last edited by neveffects; 16th February 2010 at 12:41.

Similar Threads

  1. Printing Qt
    By IsoArska in forum Qt Programming
    Replies: 1
    Last Post: 16th January 2010, 12:10
  2. Qwt Printing
    By giusepped in forum Qwt
    Replies: 3
    Last Post: 12th December 2008, 08:25
  3. Printing to PDF
    By vermarajeev in forum Qt Programming
    Replies: 8
    Last Post: 11th December 2006, 03:25
  4. Re: Printing in Qt
    By Jimmy2775 in forum Newbie
    Replies: 3
    Last Post: 12th July 2006, 23:00
  5. Qt Printing on .ps
    By vratojr in forum Qt Programming
    Replies: 3
    Last Post: 18th February 2006, 23:22

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.