Results 1 to 4 of 4

Thread: Printing Widgets: Why are they rendered into Pixmap / Bitmap?

  1. #1
    Join Date
    Jun 2010
    Posts
    3
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Printing Widgets: Why are they rendered into Pixmap / Bitmap?

    Hi all.
    my Question is very similar to this one (http://www.qtcentre.org/threads/4334...pixmap-backing) which hasn't been answered.

    How do I print Widgets "in the right way"?
    I've got a bunch of Widgets in a Layout that I want to be printed out.

    My idea was:

    Qt Code:
    1. auto printer = new QPrinter(QPrinter::ScreenResolution);
    2. ...
    3.  
    4. QPainter painter;
    5. painter.begin(printer);
    6.  
    7. //Scale to Page Size
    8. double xscale = printer->pageRect().width() / double(m_current_page->page->width());
    9. double yscale = printer->pageRect().height() / double(m_current_page->page->height());
    10. painter.scale(xscale, yscale);
    11.  
    12. content->render(&painter, QPoint(), QRegion(), QWidget::DrawChildren); //I've also simply using content->render(&painter);
    To copy to clipboard, switch view to plain text mode 

    This seemed to be very easy, but the problem now is:
    I may choose between Highresolution and slow printing and big Filesize (when printing to a PDF).
    Or: bad Resolution.

    My question is: Why does Qt print by rasterizing the whole Widgets (including their Labels etc). into Pixmaps?
    And what can I do against that?

    Or am I completely wrong when trying to print them this way?

    Thanks.
    Mr.Green

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Printing Widgets: Why are they rendered into Pixmap / Bitmap?

    Quote Originally Posted by Mr.Green View Post
    Why does Qt print by rasterizing the whole Widgets (including their Labels etc). into Pixmaps?
    Because widgets are drawn using raster graphics.

    And what can I do against that?
    Don't print widgets. Print vector graphics and text.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    Jun 2010
    Posts
    3
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Printing Widgets: Why are they rendered into Pixmap / Bitmap?

    So that means I would have to re-invent the layouting System...?

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Printing Widgets: Why are they rendered into Pixmap / Bitmap?

    I have no idea why you want to print widgets so I cannot answer your question. Usually you'd be printing documents and not widgets.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Similar Threads

  1. Replies: 2
    Last Post: 2nd November 2015, 11:20
  2. Replies: 2
    Last Post: 24th July 2011, 23:58
  3. Replies: 1
    Last Post: 19th April 2011, 11:17
  4. Replies: 20
    Last Post: 26th January 2011, 10:39
  5. Printing a pixmap full page: strange behavior on Windows
    By Pieter from Belgium in forum Qt Programming
    Replies: 8
    Last Post: 3rd March 2008, 12:29

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.