坚持QtQML,坚持移动互联网

http://www.qtcn.org/bbs/u/121778  [收藏] [复制]

toby520

将QtCoding进行到底,做Qt的宠儿

  • 89

    关注

  • 164

    粉丝

  • 3579

    访客

  • 等级:精灵王
  • 身份:论坛版主
  • 总积分:1262
  • 男,1986-11-17

最后登录:2024-05-05

更多资料

日志

Mac osx下调用打印窗口

2014-02-14 10:09
     今日群中,有人提到mac下面打印对话框无法使用的问题,遂查阅资料,几经周折,终得正果,于是再此分享一二,以便后续者不在受此困扰
     一般mac下报错为:QPrintDialog: Cannot be used on non-native printers
    查阅http://stackoverflow.com/questions/8296021/how-to-print-pdf-file-in-qt
    另外还找到qt bug系统中有解决办法https://bugreports.qt-project.org/browse/QTBUG-28822
    斟酌再三,得解:

    The issue resolved finally.
   1. The Output format for QPrinter object should be set to Native format before creating instance for QPrintDialog. It can avoid to show the message as above.
    2. The Print Support plugin should be set in the .pro file and also imported with Q_IMPORT_PLUGIN() function if it is static build.
    示例代码如下:
    
  1. QPrinter printer(QPrinter::HighResolution);
        printer.setOutputFormat(QPrinter::NativeFormat);
        QPrintDialog printDialog(&printer, this);
        if (printDialog.exec() == QDialog::Accepted) {
            // print ...
        }
    如有错误,还望指正
分类:默认分类|回复:0|浏览:2261|全站可见|转载
 

Powered by phpwind v8.7 Certificate Copyright Time now is:05-05 12:43
©2005-2016 QTCN开发网 版权所有 Gzip disabled