Results 1 to 14 of 14

Thread: [QT4] Printing a dialog

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #9
    Join Date
    Feb 2006
    Location
    USA
    Posts
    142
    Thanks
    24
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows Android

    Default Re: [QT4] Printing a dialog

    Quote Originally Posted by Chicken Blood Machine
    Your call to grabWidget() should be grabWidget(T, T->rect());
    Yeah, that makes a lot more sense
    Quote Originally Posted by Chicken Blood Machine
    Also, drop the setViewport() and setWindow() stuff.
    Done.

    Thus far, nothing is yet changing

    To re-iterate, this is what I have now:
    Qt Code:
    1. void formMainApp::menuFilePrint()
    2. {
    3. p.setColorMode(QPrinter::GrayScale);
    4. //No reason for color in this dialog
    5. p.setCreator("TIRdb");
    6. p.setDocName("TIRdb Printout");
    7. QPrintDialog qp(&p, this);
    8. if(qp.exec() == QDialog::Accepted)
    9. {
    10. QModelIndexList MIL = ui.treeViewSQLList->selectionModel()->selectedIndexes();
    11. QPainter painter;
    12. for(QList<QModelIndex>::iterator i = MIL.begin(); i != MIL.end(); ++i)
    13. {
    14. formTIR * T = TIRTree->findTIR(*i); //TIRTree is my model, findTIR returns the dialog
    15. if(!T) //Some elements in the tree do not have dialogs attached to them
    16. {
    17. continue;
    18. }
    19.  
    20. QPixmap qpm = QPixmap::grabWidget(T, T->rect());
    21. if(qpm.isNull())
    22. {
    23. qDebug() << "Failed to capture the dialog for printing";
    24. return;
    25. }
    26.  
    27. qpm.scaled(p.pageRect().width(), p.pageRect().height(), Qt::KeepAspectRatio);
    28.  
    29. painter.begin(&p);
    30. painter.drawPixmap(0, 0, qpm);
    31. painter.end();
    32. }
    33. }
    34. }
    To copy to clipboard, switch view to plain text mode 
    Last edited by KShots; 12th April 2006 at 20:12.
    Life without passion is death in disguise

Similar Threads

  1. Issue with Modelless dialog on Mac
    By Satyanarayana Chebrolu in forum Qt Programming
    Replies: 0
    Last Post: 24th February 2009, 10:10
  2. Replies: 9
    Last Post: 13th August 2008, 18:07
  3. printing QWebView before showing in Dialog
    By Grisu in forum Qt Programming
    Replies: 1
    Last Post: 17th July 2008, 12:20
  4. [QT4] QThread and printing a QList<QPixmap>
    By KShots in forum Qt Programming
    Replies: 3
    Last Post: 24th April 2006, 21:44
  5. dialog box
    By Bahar in forum Qt Programming
    Replies: 3
    Last Post: 31st January 2006, 14:52

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
  •  
Qt is a trademark of The Qt Company.