Results 1 to 2 of 2

Thread: select a printer question

  1. #1
    Join Date
    Jan 2006
    Location
    Riverside, Rhode Island, USA
    Posts
    245
    Thanks
    52
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default select a printer question

    Hi, I am running Ubuntu 8.10
    I have a table written in Qt-4. (see attachment). I want to print the table part. I have a printer connected (Deskjet-5740). I am totally confused on how to start the printer module. (I had printed this type of program when I was using Qt-3.),
    Qt Code:
    1. void PrintIndex::slotPb5()
    2. {
    3. QString path, k;
    4.  
    5. int corner[17][2];
    6. int side, m, n, count, counter, base;
    7. double a, b, x, y;
    8. bool ret;
    9.  
    10. QPrinter myprinter; // = new QPrinter();
    11. myprinter.setPageSize( QPrinter::Legal );
    12. myprinter.setOrientation( QPrinter::Landscape );
    13. myprinter.setColorMode( QPrinter::Color );
    14. myprinter.setFullPage ( true );
    15. ret = myprinter.setup();
    16. if( ret == true )
    17. {
    18. QPainter p( &myprinter );
    To copy to clipboard, switch view to plain text mode 
    I would appreciate your help very much
    Thank you

  2. #2
    Join Date
    Jan 2006
    Location
    Riverside, Rhode Island, USA
    Posts
    245
    Thanks
    52
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: select a printer question

    i am sorry but the "code" I showed before was the wrong one. This one works.

    Well, Lo and Behold, I found a program that answered my question
    Qt Code:
    1. void BaseForm::paintEvent ( QPaintEvent * )
    2. {
    3.  
    4. int xs, xe, ys, ye;
    5. int w, h;
    6. int width, height;
    7. int counter;
    8. QPainter p ( this );
    9. QPen pen;
    10. QFont f;
    11.  
    12. if ( addressList.count() == 0 ) return;
    13. f.setFamily ( "MuktiNarrow" );
    14. f.setPointSize ( 10 );
    15. p.setFont ( f );
    16. pen.setBrush ( Qt::black );
    17. p.setPen ( pen );
    18. W = ui.frmLabelBoxes->width();
    19. H = ui.frmLabelBoxes->height();
    20.  
    21. width = ( ( W-20 )-30 ) /3;
    22. height = ( H - 115 ) /8;
    23. counter = startCounter;
    24. if ( clearFlag == true ) return;
    25. for ( h = 0; h < 8; ++h )
    26. {
    27. for ( w = 0; w < 3; ++w )
    28. {
    29.  
    30. k = addressList[counter++];
    31. if ( counter > addressList.count()-1 ) return;
    32. xs = 35 + w * ( 10 + width );
    33. ys = 30 + h * ( 10 + height );
    34. xe = width;
    35. ye = height;
    36. p.drawRect ( xs, ys, xe, ye );
    37. p.fillRect ( xs+1, ys+1, xe-1, ye-1, Qt::white );
    38. k = addressList[counter];
    39. temp = k.split ( "\n" );
    40. temp[0] = temp[0].remove( "*" ); /// remove the "*" beffore the name e xtenuion
    41. count = temp.count();
    42. for ( n = 0; n < count; ++n ) p.drawText ( xs + 5, ys + 13 * ( n + 1 ) , temp[n] );
    43. endCounter = counter;
    44. }
    45. }
    46. h = endCounter;
    47. return;
    48. }
    To copy to clipboard, switch view to plain text mode 
    Guess where I found it.!!!
    In a program I wrote last year. What ever you do, don't get old.
    Last edited by impeteperry; 2nd February 2009 at 05:59.

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.