.png files in .rc (resource file) - winapi

I use .png files inside my Qt application, but to make ico for .exe file, i need use .ico,
IDI_ICON1 ICON DISCARDABLE "app.ico"
can I put app.png instead of app.ico?

I think that you can't. I took a quick glance over the Qt documentation regarding application icon's and it seems that for Windows you must use .ico filetype.

Related

How to change a file's extension to something else?

I downloaded an .R file from a zoom chat on desktop to open in Rstudio later.
Well, the .R extension was not part of the name, so I changed the name to something.pdf (of course by mistake).
The icon now looks like a pdf. I replaced the .pdf with .R. But the icon still is a PDF file and Rstudio does not recognize it as an R file.
How can I can change it back to its .R format?
edit. thanks for pointing this out. I am on a windows 10 machine. and the file is on desktop.
Troubleshoot for Windows
You may be trying to add multiple file extensions, which does not allow the file to be ready correctly.
A quick google search.
How do I reveal file extensions?
For Windows 8-10
Start Windows Explorer, you can do this by opening up any folder.
Click the View menu.
Check the box next to "File name Extensions"
Then make sure you have my_file.R as opposed to my_file.R.R.pdf.

How to preview my custom image file type as thumbnail in Windows File Explorer?

I need to add my own custom file-extension .myext to the Windows system file-types which are automatically previewed in Windows File Explorer as images in the Thumbnail view (like any other image types e.g. .png).
PLEASE NOTE: .myext files are obtained by simply RENAMING the extension of an existing .png file from .png to .myext (which should make it unnecessary to implement my own custom thumbnail handler).
So I tried the following: in the Windows Registry key Computer\HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\KindMap I added this value: .myext REG_SZ picture. Then I rebooted Windows. But the .myext files are still not viewed as image in Windows File Explorer's Thumbnails view.
So how can I preview .myext files (which as I said are renamed .png files) in Windows File Explorer's Thumbnails view?

Qt - Resources are always lost in exe built with Visual Studio

I'm trying to build a demo application with Qt in Visual Studio 2019. I used the Qt VS Tools in the Visual Studio IDE, and the Qt Designer to create my user interface. I also used the Qt SVG module in order to use SVG images for my user interface.
I achieved a working project, which works pretty well in debug and release mode, as long as I run it from the Visual Studio IDE. Now I would like to distribute it as an independent .exe file. For that I tried to create a zipped archive containing the .exe itself, the required Qt DLLs, and of course the resources the interface requires.
The compiled .exe can be executed in its own dir without problems, however none of the images I added in the resources are visible. I tried several ways to resolve the issue, and read many tutorials explaining how to use and/or embed Qt resources in the exe file. None of them worked for me.
I already tried to:
Simply copy the images in the .exe dir, keeping their dir hierarchy or not, but only the .png and .jpg images were visible, all the SVG were lost.
Compile a Qt resource file (.rcc) using the Qt rcc.exe tool, and add it to the Visual Studio resources, not worked.
Generate a .pro file using the "Create basic .pro file..." menu item (which also generated a .pri file) and add the following line, without success:
RESOURCES += MyResName.qrc
Adding the below lines in various location of my source code (main form constructor, main() function, ...). Nothing worked:
QResource::registerResource("MyResName.rcc");
...
Q_INIT_RESOURCE(MyResName)
Playing around and mixing the above mentioned ideas, nothing worked.
So can someone give me an as simple as possible explanation about how to correctly build an .exe file with its required resources, which may work in an independent way, using Qt and Visual Studio 2019, in order to distribute it, respecting the following constraints:
The project is a C++ project developed with Qt and Visual Studio 2019.
The project uses Qt, has a .ui file built with Qt Designer, which embeds several SVG and/or PNG/JPG images, and in which these images are visible in design time and if the exe is run from the IDE.
The project uses a .qrc file pointing the images, SVG or not, required for the application.
The images were added to UI components through the styleSheet property, like that:
image: url(resources/images/im-dropbox.svg) center center;
Other resources files, like .pro, .pri, .rcc, ... may be generated without problems. The required resources are well embedded in the generated files (verified).
Please help me, because this situation gives me headache.
I'll try to cover all the issues i see, in the order i see them.
First you don't use the files from resources, the Qt resource file paths start with :/ for example to set an icon from resources (in C++ code) you will do it like:
a.setWindowIcon(QIcon(":/images/window_title_ico.png"));
Now, to use resources directly from Qt Designer, you'll need to add your .qrc file for each ui file (click on that "edit" icon and then "Open resource file") after that you can set the icons from resources, see the print screen (Qt designer started from VS)
Note: you can double check the generated .ui file (it's an xml file) to see if the icon paths start with :/ then you know you have done it right. //in the .ui file you'll see something like:
<pixmap resource="resources/resources.qrc">:/images/acceleration.svg</pixmap>
//notice the relative path to the .qrc file and the .svg file path starts with :/
And lastly to display .svg on deployment, i noticed that you need to deploy the Qt5Svg.dll too (the one from the: PATH_2_QT\5.XX.X\msvcXXX_XX\bin) deploying only imageformats\qsvg.dll is not enough.
Hope this help to clear things a bit!

Default icon for .exe file regardless of Windows version

I show a bunch of exe files in a listview, and I want to show their default icon, but if the exe file has no icon resource, I would like to show the Windows default application icon regardless of the OS version. If I check the registries at:
[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\exefile\DefaultIcon]
the default value is "%1", which is the first icon in the exe file itself. But where is the default .exe icon for exe files with no icon?
This is what XP does (this is actually a shortcut, but you get the point)
It's been awhile; but doesn't shell32 handle this?
Here's an older article from stackoverflow

how to change icon in XNA

I built a game, and I wanted to change the icon (this is a windows game.) I tried removing the Game.ico that it came with and put in another , but now it just showed the standard exe file icon. All help would be appreciated.
When changing the .ico file, right-click on your project in Visual Studio and go to Properties. Select "Application" form the list on the left. In the "Resources" section browse to the icon file that you wish to use for your game.
Note that the .ico file is only used by XNA on Windows game projects and is ignored for Xbox 360 and Windows Phone 7 games. Also note that it's often easier to edit the existing Game.ico file and make your changes to that file when possible (easier because it's already linked and is in the correct format).

Resources