Results 1 to 9 of 9

Thread: change txt file type default icon

  1. #1
    Join Date
    Feb 2008
    Posts
    154
    Thanks
    12
    Qt products
    Qt4
    Platforms
    Windows

    Question change txt file type default icon

    hello everybody,
    i want to change the default icon of the txt file type on windows this can done if we chabged the following registry Key using QSettings
    HKEY_CLASSES_ROOT\txtfile\DefaultIcon\Default value
    and set it's value to the path of my program.
    how can i do that ???
    thank you.

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

    Default Re: change txt file type default icon

    But what's the problem? You know the registry path and you know QSettings. If you don't know how to use QSettings, go read its great docs full of examples:
    http://doc.trolltech.com/latest/qset...istry-directly.
    J-P Nurmi

  3. #3
    Join Date
    Feb 2008
    Posts
    154
    Thanks
    12
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: change txt file type default icon

    i just did as described in the documentation.
    it is said in the documentation that windows keys can have default value and to change it just refer to the key as follows
    Qt Code:
    1. settings.setValue("HKEY_CLASSES_ROOT\\txtfile\\DefaultIcon", "D:\\Work space\\MY Projects\\executable\\MyEditor.exe");
    To copy to clipboard, switch view to plain text mode 
    when i did that nothing happens.
    where is the wrong?
    Last edited by jpn; 20th February 2008 at 17:55. Reason: reformatted to look better

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

    Default Re: change txt file type default icon

    What does mean "nothing happens"? Did you check the value with Regedit? Shoudn't "DefaultIcon" refer to an icon file?
    J-P Nurmi

  5. #5
    Join Date
    Nov 2007
    Posts
    89
    Thanked 21 Times in 18 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: change txt file type default icon

    Try with
    Qt Code:
    1. settings.setValue("HKEY_CLASSES_ROOT\\txtfile\\DefaultIcon", "\"D:\\Work space\\MY Projects\\executable\\MyEditor.exe,0\"");
    To copy to clipboard, switch view to plain text mode 

  6. #6
    Join Date
    Feb 2008
    Posts
    154
    Thanks
    12
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: change txt file type default icon

    i tried but nothing happens the defaultIcon Key is still as it was . it was
    %SystemRoot%\system32\shell32.dll,-152
    and it is still.
    note that i tried settings.contains() to be sure that the Key is exist and be shown by
    my program and it returns true which means that the program see the Key but can not
    change it i dont know why!!!

  7. #7
    Join Date
    Feb 2008
    Posts
    154
    Thanks
    12
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: change txt file type default icon

    What does mean "nothing happens"?
    i mean that the key did not changed.
    Did you check the value with Regedit?
    yes, i checked it . it is still as it was.

  8. #8
    Join Date
    Nov 2007
    Posts
    89
    Thanked 21 Times in 18 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: change txt file type default icon

    How did you create QSettings object? It should be done this way:
    Qt Code:
    1. QSettings settings("HKEY_CLASSES_ROOT\\txtfile",QSettings::NativeFormat);
    2. // Then edit subkeys.
    3. settings.setValue("DefaultIcon", "\"D:\\Work space\\MY Projects\\executable\\MyEditor.exe,0\"");
    To copy to clipboard, switch view to plain text mode 

  9. #9
    Join Date
    Feb 2008
    Posts
    154
    Thanks
    12
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: change txt file type default icon

    when i did that a new key called DefaultIcon is added in the Path
    HKEY_CLASSES_ROOT\\txtfile
    with the value
    "D:\Work space\MY Projects\executable\MyEditor.exe,0"
    note the double quotation.
    and thank you for your co-operation.

Similar Threads

  1. dummy question(Error)
    By Masih in forum Qt Programming
    Replies: 12
    Last Post: 19th July 2007, 23:38
  2. qt-3.3.8 fail in scratchbox
    By nass in forum Installation and Deployment
    Replies: 0
    Last Post: 25th May 2007, 15:21
  3. How to dinamically change the type of a QCheckListItem
    By kalos80 in forum Qt Programming
    Replies: 4
    Last Post: 12th March 2007, 15:25
  4. Associating icon with a file type
    By munna in forum Qt Programming
    Replies: 3
    Last Post: 6th June 2006, 16:57
  5. Opening swf file in the default browser
    By munna in forum Qt Programming
    Replies: 16
    Last Post: 5th May 2006, 09:33

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.