PDA

View Full Version : How do I open .chm



Fatla
24th July 2008, 00:00
I need to open a .chm file .
I've tried :



QDesktopServices ::openUrl(QUrl("C:/Documents and Settings/User/Desktop/ubuntu.chm"));


However , nothing is happened !!

Thanks .

Fatla
24th July 2008, 12:30
I want to clarify something more ; that I need to open the chm file in order to make the user read the file .


Thanks .

high_flyer
24th July 2008, 12:59
It is not clear what do you mean by "in order to make the user read the file ."
In the docs it says:

If the URL is a reference to a local file (i.e. the URL scheme is "file") then it will be opened with a suitable application instead of a web browser.
Which means, that the extension .chm needs to be registered in the system as a file opened by a specific application - and is probably not the case on the system you are working on.

But maybe what you mean is that you want to open the file for text editing.
In such a case, you can either use QProcess (and open it with a text editor), or read the file and show its content by your self on a QTextEdit or similar.

Fatla
24th July 2008, 16:23
Thanks for your help.

I've meant by "in order to make the user read the file ." --> that the file to be opened just like if the user double clicked the .chm file .

Actually I've found out that my piece of code is working very fine .
It doesn't work as my path contains "spaces " .
I've solved this issue & saved headache by putting the .chm file I need to open beside my .exe .

Thanks .

jpn
24th July 2008, 16:34
You should use QUrl::fromLocalFile().

Fatla
24th July 2008, 17:11
Thnaks JPN .

It works fine & the space problem has been resolved by this approach .


QDesktopServices::openUrl(QUrl::fromLocalFile("C:/Documents and Settings/Admin/Desktop/ubuntu.chm"));

Thanks .