PDA

View Full Version : Open chm file using Qt in Linux



Anaswara
19th September 2017, 12:53
I have an application developed in C++ and QT that runs both in Windows and Linux(SuseLinux11). The help file was generated as a chm file. I used QDesktopServices::openurl() to open the chm file. As per the documentation of openurl():

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.

it works properly in Windows. But in Linux it tries to open using webBrowser and it fails. chmSee is installed in my Linux system which can be used to read the chm files.

Can anyone please help here.

d_stranz
19th September 2017, 17:54
chmSee is installed in my Linux system which can be used to read the chm files.

In Windows, the operating system keeps a table of file extension associations between the file extension ("pdf") and the application used to open that type ("acrobat.exe"). All QDesktopServices is doing is looking up that association and firing off the application (if the association exists) with the URL as a command line argument to the program.

I am certain there is something similar in linux. You need to set up the association between "chm" extensions and the "chmSee" app. Maybe you can do this from within the app itself or maybe there is something in a file browser app that lets you do it (like Windows Explorer's "Open with" context menu option.

Anaswara
20th September 2017, 06:13
In Windows, the operating system keeps a table of file extension associations between the file extension ("pdf") and the application used to open that type ("acrobat.exe"). All QDesktopServices is doing is looking up that association and firing off the application (if the association exists) with the URL as a command line argument to the program.

I am certain there is something similar in linux. You need to set up the association between "chm" extensions and the "chmSee" app. Maybe you can do this from within the app itself or maybe there is something in a file browser app that lets you do it (like Windows Explorer's "Open with" context menu option.


I found "/usr/share/applications/defaults.list" which maps the extensions to applications in SuseLinux. It already contains the mapping for chm files. So what next?