部署的Qt5应用程序不打印或显示打印对话框 [英] Deployed Qt5 Application Doesn't Print or Show Print Dialog
问题描述
当我从我的开发机器启动时,我看到对话框。应用程序在部署的机器上启动,但是QPrintDialog从不显示,文档不会打印。
我包含打印支持。
QT + =核心gui网络webkitwidgets小部件printsupport
我一直在使用Process Explorer来查看应用程序在我的开发机器上使用的DLL,我相信一切都存在。我的应用程序包包括:
- {myAppPath} \MyApp [MyApp.exe,Qt5PrintSupport.dll,...]
- {myAppPath} \plugins\printsupport\windowsprintersupport.dll
- {myAppPath} \plugins\imageformats [qgif.dll,qico.dll, qjpeg.dll,qmng.dll,qtga.dll,qtiff.dll,qwbmp.dll]
以下是相关的代码段:
void PrintableForm :: printFile()
{
//将PDF写入磁盘环境
pdfCopy();
//纸张复制只适用于我的开发机器
QPrinter paperPrinter;
QPrintDialog printDialog(& paperPrinter,this);
if(printDialog.exec()== QDialog :: Accepted){
view-> print(& paperPrinter);
}
this-> accept();
}
我的第一个想法是相关的DLL没有被发现是打印时间,这意味着我的应用程序文件系统不正确,但是我没有找到任何可以显示不同文件结构的东西。我在正确的轨道上还是有其他错误的设置?
这是另一个经典的Windows / Qt5部署问题将错误的插件和插件的组合放在不正确的位置。通过使用环境变量QT_DEBUG_PLUGIN并将PROIG + = CONSOLE添加到我的PRO文件中,我可以看到在我的开发机器上的应用程序正在加载我没有发货的qminimal.dll。
我定义为{myAppPath} \的应用程序根是插件的根目录。因此,正确的文件结构是:
- {myAppPath} \MyApp [MyApp.exe,Qt5PrintSupport.dll,...] li>
- {myAppPath} \platforms [qwindows.dll,qminimal.dll]
- {myAppPath} \printsupport *
- {myAppPath} \imageformats *
- {myAppPath} \bearer *
I'm experiencing Qt4 to Qt5 troubles. In my application when the user clicks the print button two things should happen, one is that a PDF gets written to disk (which still works fine in the new version, so I know that some of the printing functions are working properly) and the other is that a QPrintDialog should exec() and then send to a connected printer.
I see the dialog when I launch from my development machine. The application launches on the deployed machine, but the QPrintDialog never shows and the document never prints.
I am including print support.
QT += core gui network webkitwidgets widgets printsupport
I have been using Process Explorer to see what DLLs the application uses on my development machine, and I believe that everything is present. My application bundle includes:
- {myAppPath}\MyApp[MyApp.exe, Qt5PrintSupport.dll, ...]
- {myAppPath}\plugins\printsupport\windowsprintersupport.dll
- {myAppPath}\plugins\imageformats[ qgif.dll, qico.dll,qjpeg.dll, qmng.dll, qtga.dll, qtiff.dll, qwbmp.dll ]
The following is the relevant code snippet:
void PrintableForm::printFile()
{
//Writes the PDF to disk in every environment
pdfCopy();
//Paper Copy only works on my dev machine
QPrinter paperPrinter;
QPrintDialog printDialog(&paperPrinter,this);
if( printDialog.exec() == QDialog::Accepted ) {
view->print(&paperPrinter);
}
this->accept();
}
My first thought is that the relevant DLLs are not being found come print time, and that means that my application file system is incorrect, but I have not found anything that shows me a different file structure. Am I on the right track or is there something else wrong with this setup?
This was another classic Windows/Qt5 deployment problem with a combination of missing plugins and plugins placed in incorrect places. By using the environmental variable QT_DEBUG_PLUGIN and adding CONFIG += CONSOLE to my PRO file I was able to see that on my development machine the application was loading qminimal.dll which I was not shipping.
The application root which I have defined as {myAppPath}\ is the root directory for plugins. Therefore the correct file structure is:
- {myAppPath}\MyApp[MyApp.exe, Qt5PrintSupport.dll, ...]
- {myAppPath}\platforms[qwindows.dll,qminimal.dll]
- {myAppPath}\printsupport*
- {myAppPath}\imageformats*
- {myAppPath}\bearer*
Thanks peppe for the lead.
这篇关于部署的Qt5应用程序不打印或显示打印对话框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!