QT/C++ on MAC - Application Icon doesn't set - qt

Weird problem I'm struggling with. On the same folder as my "*.pro" QT project file I have a Resources/myIcon.png.
I am trying to set that as the Icon for my built application, running on OSX. I read the documentation and it suggests to put a "ICON = " in the .pro file. I did that, but for some reason, the icon IS copied over the the resources folder inside my app's content, but the .pfile's icon field remains empty. Even when I change it manually to "resources/myIcon.png" it will not work.
What am I doing wrong?

Manually delete the generated app bundle. Run QMake followed by Rebuild All is not sufficient!

Don't set the full pathname within the application bundle for the icon file in the Info.plist. Just set the filename. Mac OS knows to look in AppName.app/Contents/Resources for it.
And yes, it must be an ICNS file as far as I'm aware. You can use the 'Icon Composer' utility that is part of the Mac OS development tools to create an .icns from a .png.

Are you referring to the icon which appears in the dock? I added a .ico to my application's resource file, then set it as my icon with the following call
QApplication::qApp()->setWindowIcon(QIcon(<resource path>));

Related

Possible to change the application file's icon?

I'm using Inno Setup to create a Windows software installer, and would like to use a custom icon for the distributed exe file (which will be located in C > Program Files > MyProgram ).
So far, I've been able to get the custom icon to work (sort of) for the desktop shortcut, by using the following code, placed under the [Icon] section...
Name: "{commondesktop}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; IconFilename: "{app}\TheIcon.ico"; Tasks: desktopicon
When I say that it "sort of" worked... it did customize the desktop shortcut's icon, but the quality of the icon looks terrible compared to the quality of the original icon.
But the bigger issue is... I can't figure out how to customize the icon for the actual application (exe) file at all, or for the start menu shortcut.
I would have assumed that the following line would do the trick for the application file...
Name: "{pf}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; IconFilename: "{app}\TheIcon.ico";
And I also assumed that the following code would do the trick for the start menu icon...
Name: "{commonstartup}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; IconFilename: "{app}\TheIcon.ico";
But no dice. It just uses the default icon.
Can anyone tell what I'm doing wrong? I would post the entire script here but it seems that the Stack Overflow code editor doesn't like a bunch of curly brackets over multiple lines (if someone knows a way around that I'll be happy to post the whole script).
And FYI... for this particular project, changing the exe icon prior to running it through Inno Setup doesn't appear to be an option (I tried changing it via Resource Hacker, and although it succeeded in changing the exe's icon, it corrupted the file in the process, to where it wouldn't even run :(
If it's not possible to customize the application file's icon using Inno Setup, then do I have any other options?
As you know the application icon is built into the .exe file. The Inno Setup cannot modify the .exe files. And there's no other way to override the application icon by an external one.
You have to edit the .exe file yourself, before building the installer.
I personally use the Resource Hacker and have no problems with it.
Make sure the license of the application you are modifying allows such customization.
The icons in Windows Start menu are indeed set using IconFilename. I also have no problems with that.
The problem might be that Windows caches the Start menu icons. So if you had that entry in Start menu before, reinstalling the application with new icons sometime won't make Windows reset the cache. It keeps displaying the old icons. Try to uninstall, restart, and reinstall.

Sublime Text 2 - Changing the icon on Windows

As the title says, how do you change Sublime Text 2 default icon on Windows(7 or 8)?
I've searched everywhere. I found the post by Jeffrey Way on Nettuts that explains how to change it on the Mac and it was as simple as putting the 'nameoftheicon.icns' file somewhere in the default folder.
Now I have two problems:
1) I can't find the folder where the icns file should be put in
2) on Git(or somewhere else) when I find the repo of an icon the things to do in order to change it, even on the Mac, are way longer than Jeff's post
I wish the Windows folder was specified in that post to but it isn't(as you know he works on Mac).
So basically what's the fastest way to change the icon, maybe just by putting the icns files somewhere and avoiding the download of external software(as some Git repos suggests)?
There is no way of changing the icon on Windows without editing either the sublime_text.exe file or one of the libraries with an external program. It's just one of the many, many differences between Windows and Mac. .icns files are specific for the Mac platform, and don't exist in the Windows versions of Sublime Text.
There is no easy/fast method to change an application icon once its been compiled, however you can use a tool like Resource Tuner to alter the resources embedded within it.
Its worth noting that if you do use Resource Tuner it only supports 32bit binaries which means you will need to modify the 32bit version of Sublime. You can adjust the four icons defined there (16,32,48 256), you will need to create your own individual ICO files for each 32bit resource, import them using resource tuner and then save our .exe
An altered 32bit version of the .exe and .ico resources are here : https://copy.com/S7kKk6rh2Q3P12iu (nothing malicious however use at your own risk)
suggest https://github.com/dbmzzo/Sublime-Text-2-Icon
may help. BTW, it provide solution of changing icon in Win\Ubuntu\Mac

Why Files misteriously disappear from xcode with this strange symptom?

I use time machine and drop box to synchronize stuffs.
Recently I found that some files are gone.
However, the project compiles just fine as if the file is there. My friend cannot compile though.
This is very frustating. I got to find the missing files and then restore it from time machine and then readd that to xcode. I don't even know what files are missing.
I used dropbox and time machine. Looks like file disappear, the file names becomes "red" in xcode for a while and then poof it's gone. Xcode automatically remove the files from the project. The project still compiles fine which is frustating. If the project doesn't compile, I will know ah this file is missing.
Looks like somehow xcode still have the file but doesn't show it. Files is not on finder either.
What could possibly be the explanation and how to fix that.
I have clean projects to make sure that my computer do not use cached files.
It still compile fines in my computer
The file is still missing in project navigator
My friends' computer that uses the EXACT same files (connected to drop box) cannot compile
For example, xcdatamodeld files are crucial. In my computer it still run fine without that file even though that file is obviously needed. Xcode behaves as if the file is there all along.
My friends' try to compile the project and crash.
Also there is a PNG file. In my computer it runs fine with the icons showing up. In my friends computer the icons doesn't show up at all.
For anyone who still have the problem, in my case Xcode6. It turns out somehow the "Show only files with source control status" and "Show recent file button" is enable. It located in the bottom of left sidebar.
This somehow happen after I update os to Yosemite.
Cheers
Go to the project navigator (top left folder symbol). Files that are not found by XCode are displayed in red. But since your project compiles fine, there should not be any that are required. Now click one of the "missing" files to activate it. Open the utility area on the right side, and show file inspector. Under "location" you find the full path of this file. Probably, your XCode project uses just references to these "missing" files that are stored somewhere else, and not in your project folder.
I had the same problem ..then I added the files explicitly into our project…which resulted into Duplicate Symbols error …we solved that by following….
In Your Project go to targets-
At the bottom Bar of your Targets there are three options..
1.Add Target
2. Validate Settings
3. Build RUle..
Click on validate Settings….it will ask for you to remove the Duplicated files from the project do it…ur project would run fine

Using Qt Creator in QML Design mode, how to reference an image using qrc path?

So, we have an embedded Linux system running Qt and we compile all of our icons (.png format) into our executable using the resource file. The problem is that I want to be able to use the Qt Creator QML Designer to visually see our screens as we are laying them out, but it only allows me to select a relative file system path (i.e. not a path to the resource). If I go to edit mode and put the qrc:/image.png it works in run time but the image doesn't show up in the QML Design mode. Has anyone ever done this or know if it is possible?
There is at least a workaround:
Put everything in the resource file (the qml files and the icons), and when you'll edit the file in Qt Quick Designer, all paths will be relative so the icons will be visible.
Everything is described there: Managing resource files with the Qt resource system
And to avoid deploying the qml files, you'll have to remove/comment the following line from your .pro:
DEPLOYMENTFOLDERS = folder_01
and replace it with:
OTHER_FILES = <list of qml files>

Qt/C++: Icons not showing up when program is run

I've added a QAction to my QToolBar in my MainWindow in Qt Designer (using the Qt Creator IDE) and given that Action an icon (done by "Choose File" and selecting my .png located in the same directory as my project and source code). The icon shows up fine in the toolbar in Qt Designer, but does not show when the project is running. I've had similar trouble when choosing the title bar icon on windows. I've never used graphics in Qt before, is there something special I need to do?
Screenshot:
I found myself doing all the right stuff, adding a qrc file and placing my icons there. When I run the program no deal.
Turn out I was forgetting to run qmake:
Right click your project's name and select "Run qmake". Or go to Build>Run qmake.
Everytime you change something in the .pro file you need to run qmake again. Creating a resource file implicitly adds argunments to the .pro file, so you need to do it.
Hope it helps other people out there.
Did you make a QRC file (that is, Qt's equivalent of a resource file?)
If not, that would explain what you're seeing. The icons will show up in the creator, but not in the final compiled executable. Have a look at this:
http://doc.qt.io/qt-5/resources.html
Also in case of shadow build don't forget to use windeployqt.exe on your application executable file. After that several folders will be added to your build directory. Particulary two important folders: iconengines and imageformats which contain several dlls needed to load and draw the icon.
Have you tried opening up the Project file. For example, my project file is named menu.pro and it contains the following:
TEMPLATE = app
QT = gui core
CONFIG += qt debug warn_on console
DESTDIR = bin
OBJECTS_DIR = build
MOC_DIR = build
UI_DIR = build
FORMS = ui/mainwindow.ui
HEADERS = src/mainwindowimpl.h
SOURCES = src/mainwindowimpl.cpp src/main.cpp
RESOURCES = Images.qrc
The last line (RESOURCES = Images.qrc) is what you need to put in your project file: of course, use the name that you used for your resources file, in my case, it is Images.qrc.
While adding icons use "Choose Resource" option instead of "Choose
File" option.
Right click your project's name and click "Run
qmake".
Also make sure you don't forget to include the qrc file in the code (e.g. in main(...)) with Q_INIT_RESOURCE(MyIconResource);
This can also lead to missing icons in the final exe.
I also faced such a problem. In my case, I closed qt creator and deleted the build folder (something like build-projectname.. ). Then restarted qt creator. Then magically my icon showed up on running application.
I often use this trick when qt doesn't behave well.

Resources