Results 1 to 5 of 5

Thread: How to put an icon on file extensions of a Qt program on Windows Explorer

  1. #1
    Join Date
    Jan 2016
    Posts
    76
    Thanks
    28
    Thanked 1 Time in 1 Post
    Qt products
    Qt5
    Platforms
    Windows Android

    Default How to put an icon on file extensions of a Qt program on Windows Explorer

    Hello,

    Here is the program. On the Web I found:

    Qt Code:
    1. QSettings reg("HKEY_LOCAL_MACHINE\\SOFTWARE\\Classes\\.sp\\DefaultIcon",
    2. QSettings::NativeFormat);
    3. reg.setValue("Default", "C:\\Users\\Tomy\\Desktop\\package_directory"
    4. "\\packages\\com.vendor.product\\data\\Spreadsheet.ico");
    5.  
    6. SHChangeNotify(SHCNE_ASSOCCHANGED, SHCNF_IDLIST, NULL, NULL);
    To copy to clipboard, switch view to plain text mode 

    I put this in void MainWindow::writeSettings() and void MainWindow::readSettings() in the code. And then created an installer using Qt Installer Framework and installed it on Windows.
    No icon!
    Any idea?

  2. #2
    Join Date
    Sep 2017
    Posts
    29
    Thanks
    3
    Thanked 2 Times in 2 Posts
    Qt products
    Qt5 Qt/Embedded
    Platforms
    Windows

    Default Re: How to put an icon on file extensions of a Qt program on Windows Explorer

    Quote Originally Posted by franky View Post
    Hello,

    Here is the program. On the Web I found:

    Qt Code:
    1. QSettings reg("HKEY_LOCAL_MACHINE\\SOFTWARE\\Classes\\.sp\\DefaultIcon",
    2. QSettings::NativeFormat);
    3. reg.setValue("Default", "C:\\Users\\Tomy\\Desktop\\package_directory"
    4. "\\packages\\com.vendor.product\\data\\Spreadsheet.ico");
    5.  
    6. SHChangeNotify(SHCNE_ASSOCCHANGED, SHCNF_IDLIST, NULL, NULL);
    To copy to clipboard, switch view to plain text mode 

    I put this in void MainWindow::writeSettings() and void MainWindow::readSettings() in the code. And then created an installer using Qt Installer Framework and installed it on Windows.
    No icon!
    Any idea?
    Just find a book and learn it.

  3. #3
    Join Date
    Jan 2016
    Posts
    76
    Thanks
    28
    Thanked 1 Time in 1 Post
    Qt products
    Qt5
    Platforms
    Windows Android

    Default Re: How to put an icon on file extensions of a Qt program on Windows Explorer

    Do you have a book on that to suggest?

  4. #4
    Join Date
    Jul 2008
    Location
    Germany
    Posts
    503
    Thanks
    11
    Thanked 76 Times in 74 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: How to put an icon on file extensions of a Qt program on Windows Explorer

    Hi, there are multiple possible errors:
    - the code never got executed
    - the path is incorrect (e.g. the fix user name)
    - the icon file Spreadsheet.ico does not exist

    Can you see in regedit that the value got changed?

    Ginsengelf

  5. #5
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,230
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: How to put an icon on file extensions of a Qt program on Windows Explorer

    On current Windows platforms (Windows 7+) ordinary users are generally not permitted to write to HKEY_LOCAL_MACHINE except with elevated permissions (such as occurs at program install time or when running as administrator).

    Even if you have permission, I am not sure if QSettings will create the registry path if it does not already exist. If it does, then see Ginsengelf's comments too.
    <=== The Great Pumpkin says ===>
    Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.

Similar Threads

  1. Replies: 5
    Last Post: 5th August 2009, 18:32
  2. Obtaining a Windows file icon using fromWinHBITMAP()
    By DIMEDROLL in forum Qt Programming
    Replies: 2
    Last Post: 3rd October 2008, 12:50
  3. Associate Program Icon for Windows Desktop
    By brent99 in forum Newbie
    Replies: 2
    Last Post: 11th March 2008, 05:22
  4. icon visible from explorer
    By ChasW in forum Qt Programming
    Replies: 2
    Last Post: 9th February 2007, 22:30
  5. windows explorer
    By denis in forum Newbie
    Replies: 1
    Last Post: 25th January 2006, 06:59

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.