Results 1 to 6 of 6

Thread: How do I open .chm

  1. #1
    Join Date
    Jun 2008
    Posts
    35
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Windows
    Thanks
    5
    Thanked 3 Times in 2 Posts

    Default How do I open .chm

    I need to open a .chm file .
    I've tried :

    Qt Code:
    1. QDesktopServices ::openUrl(QUrl("C:/Documents and Settings/User/Desktop/ubuntu.chm"));
    To copy to clipboard, switch view to plain text mode 

    However , nothing is happened !!

    Thanks .

  2. #2
    Join Date
    Jun 2008
    Posts
    35
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Windows
    Thanks
    5
    Thanked 3 Times in 2 Posts

    Default Re: How do I open .chm

    I want to clarify something more ; that I need to open the chm file in order to make the user read the file .


    Thanks .

  3. #3
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows
    Thanks
    21
    Thanked 418 Times in 411 Posts

    Default Re: How do I open .chm

    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.
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  4. #4
    Join Date
    Jun 2008
    Posts
    35
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Windows
    Thanks
    5
    Thanked 3 Times in 2 Posts

    Default Re: How do I open .chm

    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 .

  5. #5
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts

    Default Re: How do I open .chm

    You should use QUrl::fromLocalFile().
    J-P Nurmi

  6. #6
    Join Date
    Jun 2008
    Posts
    35
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Windows
    Thanks
    5
    Thanked 3 Times in 2 Posts

    Default Re: How do I open .chm

    Thnaks JPN .

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

    Qt Code:
    1. QDesktopServices::openUrl(QUrl::fromLocalFile("C:/Documents and Settings/Admin/Desktop/ubuntu.chm"));
    To copy to clipboard, switch view to plain text mode 

    Thanks .
    Last edited by jpn; 24th July 2008 at 18:17. Reason: missing [code] tags

  7. The following 2 users say thank you to Fatla for this useful post:

    vycke (11th February 2009), WinchellChung (28th August 2008)

Similar Threads

  1. Replies: 3
    Last Post: 7th October 2015, 20:43
  2. QTextBrowser: Cannot open
    By veda in forum Qt Programming
    Replies: 3
    Last Post: 27th December 2007, 13:05
  3. again Open Cascade + Qt 4.2.2 but detailed...
    By Shuchi Agrawal in forum Qt Programming
    Replies: 11
    Last Post: 1st February 2007, 08:03
  4. again Open Cascade + Qt 4.2.2 but detailed...
    By Shuchi Agrawal in forum Qt Programming
    Replies: 1
    Last Post: 18th January 2007, 07:50
  5. Replies: 11
    Last Post: 24th March 2006, 07:40

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.