[Qt-interest] How to print out widgets?

Jason H scorp1us at yahoo.com
Tue Jun 15 18:02:48 CEST 2010


I would probably try not rendering directly to a printer, bu rather a pixmap, that is then scaled to the printer. It is likely that the drawing commands to the printer did not translate properly. Printers deal with bitmaps, text, or vectors, and there are numerous quirks to them. By capturing it as a pixmap first, you'll then load an image to the printer, rather than some mixed-mode rendering. I'd expect render() to try a combination of vectors and bitmaps. Also, coordinate spaces are different. 

So capture as an image, then print the image.







________________________________
From: M. Bashir Al-Noimi <admin at mbnoimi.net>
To: qt-interest at trolltech.com
Sent: Tue, June 15, 2010 12:15:25 AM
Subject: [Qt-interest] How to print out widgets?


Hi folks,

I tried to print out
QTableWidget as shown below:

    QPrinterprinter; 
    printer.setPageSize(QPrinter::A4);
    QPrintDialog print(&printer , this);
    QPainter painter(&printer);
    if(print.exec()== QPrintDialog::Accepted)
    {
        ui->tableWidget->setFixedWidth(250);
        ui->tableWidget->render(&painter, QPoint(100, 100));
    }

but it didn't print out anything and gave me the following error
message instead:


QWin32PrintEngine::drawPixmap,
StretchBlt failed (Not enough storage is available to process this
command.)


How I can fix this
issue?


-- 
Best Regards
Muhammad Bashir Al-Noimi
My Blog: http://mbnoimi.net



      
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20100615/7ca6f0a0/attachment.html 


More information about the Qt-interest-old mailing list