Qt 无法在 Windows 上检测打印机
我在 Windows 7(32 位)上将 Qt 用于项目(Qt 5.0.2,预编译并从 qt-project.org 下载),但在尝试打印文档时遇到问题.
I'm using Qt for a project (Qt 5.0.2, precompiled and downloaded from qt-project.org) on Windows 7 (32-bit) and I'm having trouble trying to print a document.
qDebug() << QPrinterInfo::availablePrinters().size(); // 0
我可以打印为 PDF,并且我在其他计算机上测试了相同的可执行文件,效果很好.我确实安装了打印机,并且可以从任何其他程序(例如记事本或 Word)正常打印.关于为什么它返回一个空列表的任何线索?我在任何地方都找不到这种行为的记录,这是 Qt 错误吗?
I'm able to print as PDF and I tested the same executable in other computers, it works just well. I do have printers installed and I can print normally from any other program such as notepad or Word. Any clue on why is it returning an empty list? I can't find this behavior documented anywhere, is this a Qt bug?
当你部署你的 Qt 应用程序时,你应该把
When you deploy your Qt application, you should put
[your Qt application]\printsupport\windowsprintersupport.dll
库 windowsprintersupport.dll 应取自
The library windowsprintersupport.dll should be taken from
[Qt path]\[platform]\plugins\printsupport
附言第一个答案几乎是正确的,除了路径的名称.
P.S. The first answer is almost correct, except path's names.