Results 1 to 5 of 5

Thread: QPrinPreview differences between Windows and Linux

  1. #1
    Join Date
    May 2008
    Posts
    276
    Thanks
    13
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default QPrinPreview differences between Windows and Linux

    I use the same code for print preview. But in Windows I get a quite different preview from Linux.
    See the attached screenshots.
    Why?
    Attached Images Attached Images

  2. #2
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: QPrinPreview differences between Windows and Linux

    Can you show us your code? From the screenshots it seems that you don'T have specified the pagesize and therefor it uses the default pagesizes on the platforms, which could differe.

  3. #3
    Join Date
    May 2008
    Posts
    276
    Thanks
    13
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QPrinPreview differences between Windows and Linux

    Qt Code:
    1. void MainWindow::printPreview(){
    2. QPrinter print(QPrinter::HighResolution);
    3. print.setPaperSize(QPrinter::A4);
    4. print.setPageSize(QPrinter::A4);
    5. QPrintPreviewDialog preview(&print,this);
    6. connect(&preview, SIGNAL(paintRequested(QPrinter *)), SLOT(printPreview(QPrinter*)));
    7. preview.exec();
    8. }
    9. ...
    10. void MainWindow::printPreview(QPrinter* p){
    11. printReport(p,0);
    12. }
    To copy to clipboard, switch view to plain text mode 
    In printPreview there is a call to a method in a class:
    Qt Code:
    1. ...
    2. m_document->setPageSize(printer->pageRect().size());
    3.  
    4. ...
    5. QString site =" <table bgcolor=\"lightGray\" border=\"0\"><tbody><tr ><td width=\"800\">" + QObject::tr("Sito") +"</td></tr></tbody> </table>";
    6. m_cursor.insertHtml(site);
    7. m_cursor.insertText(QObject::tr("Sito"),boldFormat);
    8. m_cursor.movePosition(QTextCursor::EndOfBlock);
    9.  
    10. int pw = printer->pageRect().width();
    11. int ph =printer->pageRect().height();
    12.  
    13. p.begin(printer);
    14.  
    15. p.save();
    16. m_document->adjustSize();
    17. QTransform tra;
    18. tra.scale(11,11);
    19. p.setTransform(tra);
    20. ...
    21. m_document->drawContents(&p,printer->paperRect());
    22.  
    23. p.restore();
    24. p.end();
    To copy to clipboard, switch view to plain text mode 

  4. #4
    Join Date
    Apr 2010
    Posts
    11
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QPrinPreview differences between Windows and Linux

    Hi, I have a different problem with QPrintPreviewDialog on Linux. The initial size of the preview window is too small. How do I set the size of the preview window?

  5. #5
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: QPrinPreview differences between Windows and Linux

    QPrintPreviewDialog is a normal dialog. So just use QWidget::geometry or QWidget::adjustSize().

Similar Threads

  1. How to port windows app to linux
    By sudheer168 in forum Qt Programming
    Replies: 4
    Last Post: 15th October 2009, 08:39
  2. Replies: 2
    Last Post: 22nd July 2009, 20:16
  3. Deployment Procedure On Windows On Linux and Windows
    By Harshith J.V. in forum Installation and Deployment
    Replies: 4
    Last Post: 9th July 2009, 11:27
  4. Replies: 5
    Last Post: 15th January 2009, 09:03
  5. QPalette works differently on windows and linux
    By babu198649 in forum Newbie
    Replies: 3
    Last Post: 6th March 2008, 07:27

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.