Open an external file from qt
Hello,
I'm trying to open a .pdf file from qt. I have develop the following code to achieve my goal:
Code:
#include <QDesktopServices>
#include <QUrl>
exercise
::exercise(QWidget *parent
){
ui.setupUi(this);
connect(ui.open,SIGNAL(clicked()),this,SLOT(openDocument()));
}
exercise::~exercise()
{
}
void exercise::openDocument()
{
desk.
openUrl(QUrl("file://C:/a.pdf"));
}
Can someone help me? i have read the post about this thread, but i'm not capable to solve the problem.
Re: Open an external file from qt
Ok, but what exactly is the problem?
BTW. Take a look at QUrl::fromLocalFile()
Re: Open an external file from qt
the problem is that when I pushed the button no file has shown.
Re: Open an external file from qt
i have get it!
but is any function in qt to open a pdf without havin installing into my software the adobe reader?
Re: Open an external file from qt
I dont think so.. though I guess there are 3rd party libraries to do that
Re: Open an external file from qt
There is poppler but I don't know if it supports Windows.
Re: Open an external file from qt
Qt is not shipped with a pdf viewer, so to view pdf files:
you can embed adobe ActiveX control in your app,
or fires up the adobe reader ,
or use some third parties libraries (Poppler is the most known).
Re: Open an external file from qt
ok, i will try with poppler.
one question more please! Nowadays I want to see the .pdf into a text edit but problems occured. why? i have written this comand:
ui.textEdit->desk.openUrl(QUrl("a.pdf"));
thanks
Re: Open an external file from qt
This is not even a proper C++ syntax... And even if it was, you can't expect an application framework to do everything you could imagine it would be good to have. You can't place PDF files into QTextEdit. Please launch Qt Assistant, type in "QDesktopServices" in the index tab and read the description of what the class does.
Re: Open an external file from qt
you are right! i cannot use it-