PDA

View Full Version : How to embed PPT in Qwidget



mouni
4th August 2016, 15:18
Hi,


I am trying to embed PPTViewer application in QAxWidget but it is showing blank .plz help here is my code...

QString nPath;
nPath = QFileDialog::getOpenFileName(this,"select PPT files",qApp->applicationDirPath(),"*.ppt *.pptx");

QAxWidget *m_pAxWidget = new QAxWidget(this);
if(!m_pAxWidget->setControl("PowerPoint.Application"))
{
QMessageBox::critical(this, trUtf8("Error PPT"), "Install Microsoft Power Point (R) for support PPT!");
}
ui->gridLayout->addWidget(m_pAxWidget);
m_pAxWidget->setControl(nPath );

d_stranz
5th August 2016, 16:51
So, you check the error in the first call to setControl(), but then you just continue on and call setControl() again, this time with the name of the document file instead. If it didn't work the first way, why do you think it would work the second time instead?

I hope you realize that this question is exactly the same as the question you asked a few days ago about WordViewer. If your system doesn't have the proper ActiveX controls for viewing MS Office documents installed, no amount of variation on the way you try to instantiate the ActiveX controls is going to make them magically display the documents on screen.

Instead of wasting time posting different versions of a question who cause is the same problem, why don't you investigate what is wrong with your system configuration and fix it?

You are also relying on a multiple-step process by which Windows has to (1) parse the name of the document, (2) determine the type of document it is (solely from its extension in this case), (3) look up in the Registry the correct ActiveX server that is registered as the handler for such documents, (4) instantiate the server process, (5) load the document into the server process, (6) find an ActiveX control within the server that can display the document on-screen, (7) instantiate the display control, and finally (8) render the document into the display control. And your code is doing this without error-checking anywhere.

The best way for you to implement what you want to do is to read the documentation on QAxBase::setControl(), look up the CLSID for the Word / PPT / Excel / Visio / whatever servers you want to use, instantiate them using the low-level CLSID-based calls, then use the COM classes in the MS Office COM Automation objects to open and display your documents. If you rely on WIndows to do all the work for you based on a high-level procedure, you have no way to determine what is going wrong or why.