Setting the application icon with CMake - c++

Is there a cross-platform way to set the application icon with CMake? I am using Cmake 3.0.2 with Qt 5.4.
In the Qt documentation a method is shown but it is not cross-platform.

CMake doesn't handle this for you.
On some platforms are are several "application icons". For example, on a UNIX-like system which follows the FreeDesktop.org standards (essentially anything you can see today on Linux, no matter if it's KDE, Gnome, Unity, XFCE or some other DE-du-jour), this is done by setting an appropriate Icon entry in the application's .desktop file. See the .desktop spec for details. This is what gets shown as a launcher's icon, and some DEs such as the recent Plasma will use this for a window icon in the taskbar, with appropriate theme overrides.
Maybe you are shipping a Windows installer, too, perhaps based on the NSIS. Then you should probably specify this in your .nsi as well.
Actual window icons are something which should be set up by the programmer, too. As you can see, there's plenty of places where an "application icon" might be set. If you're looking for a real-world example, check out Trojitá's source code. Look for actual icon file installation through CMake, for the NSIS code, for creating a Windows RC file, and finally for setting the application icon from the C++ code.

Related

No output from heob in a Qt application using Qt Creator

I would like to use heob to check my app for memory leaks. This is what i tried: I opened the project "analogclock" from the examples collection in qtcreator. After that i have chosen "Analyze" and "Heob" from the drop down menu. After choosing the heob path and a click on the ok button, the application starts and a console window "heob32" is displayed. But now nothing happens. Just the word "kill" is displayed in the console window. I can´t see any output and if i close the analogclock app i get the message: "heob: cannot create target process". Can anyone help me further to get useful output from heob?
What OS are you using and what heob did you install?
You need to download and install heob separately from Creator. Creator just installs a link without heob itself. Have you done this? Are you really running on a 32-bit system (there is a heob64 in case you are using a modern OS).
Did you configure your heob installation in Qt Creator correctly?
Can you run heob from the commandline with reasonable behaviour?

Cannot Connect to QML Emluation Layer (QML Puppet)

I just made the fresh QT installation and when I create empty QT Quick project or open any of existing QT Quick examples, my QML designer doesn't work. It shows "Cannot Connect to QML Emluation Layer (QML Puppet)" error.
I tried to reinstall QT, reboot, installed additional QT kit versions and tried to switch between 32bit/64bit default/opengl versions of the kit and nothing seems to work for me. I was able to successfully run the designer ONCE, and after I closed it and tried to re-open the file it stopped working again. I also tried to search, but didn't find any solution. I also tried to ask on QT forums, but didn't receive any answer.
My system is Windows 7, with Visual Studio 2013 installed. Thanks for your help!
Do this:
Go to QT Creator Preferences (Menu Bar | Tools > Options)
Select QT Quick Option (Options headings - left side).
Click the QT Quick Designer tab.
Under QML Emulation Layer grouping, select "Use QML Emulation Layer that is built with selected QT".
No need to choose a path,
And click OK.
It will rebuild your designer view.
Worked for me.
Possibly related to this bug. Just try this workaround: in the Options
dialog go to “Qt Quick / Qt Quick Designer / QML Emulation Layer” and
disable the checkbox “Always use the QML emulation layer prived by Qt
Creator”. That will cause a rebuild of the emulation layer with the
used Qt version in the current project. That layer does not crash.
This workaround only works with Desktop Kits. – BaCaRoZzo Mar 30
This worked for me on Ubuntu 14.04.
Go to Tools->Options->Qt Quick.
In QML Emulation Layer, make sure
the path is correct for "Use fallback QML emulation layer".
Since I was reinstalling Qt, the new installation had the old path of Qt which gave rise to this issue.
If failed anyway, use "Qt Design studio" instead and build it again, it worked for me.
I recommend to uninstall Qt first and then reinstall it with "Qt Design Studio" box checked.
On Ubuntu 20 LTS, you can run it on: /home/Qt/Tools/QtDesignStudio/bin/qtdesignstudio
Good luck.

using qt creator only as editor: are qt libraries necessary

I want to use qt creator, only as an editor, which does code completion and finds declarations etc. I dont want to use it to build etc. Is there a way, I can circumvent the need of qt-libraries? I am using a server, where my file space is limited. Also, without qt libraries, it does not allow making even a project. When I tried to install qt-libraries, it configures fine, but on make gives error.
So, can you suggest an alternative? Thanks
No, you need the Qt libs because the editor was coded in Qt.
Actually - at least under Windows -, you can. You just have to deselect all Qt library versions and only select the editor. If you want to have a debugger available on Windows, also select the checkbox for CDB support.
I have forgotten how this works with the Linux installer, but I imagine the same applies there as well, except of course for the CDB debugger, which is not available on Linux. Instead you should be able to chose from GDB and some other alternatives, though it might not be during the installation.
Once you installed it and are about to set up a new "Plain C++" project, you can't select a Qt version when creating a new kit, obviously.
If you blindly selected an already existing kit, Qt Creator might have tried to use a Qt installation for your vanilla C++ project. Instead of doing so, you should click the "Manage..." button on one of your preexisting kits and add a new, custom kit. Here you can set the "Qt version" option to "None". The rest should be set according to your needs.

Qt Creator - how to set application icon for ubuntu linux?

I have seen the original question qt-creator-how-to-set-application-icon
but it did not help me because i am building an app in ubuntu and the Qt`s Documentation
is not clear for me..
Is there anynone, who has done it?
Whats the method?
Thanks in advance.
Linux does not have any standard for reading embedded resources, so there is no way to embed the icon in the application binary itself and have it display in the menu and launcher. You will have to install your icon in the appropriate pixmaps directory and a .desktop file in appropriate apps directory pointing to your application and respective icon.
The Qt documentation you quoted refers to icon theme specification, which describes where the files should be installed. Look for the Installing Application Icons towards the end for summary of what needs to be done.
You will have to install the files in the "install" target of your build system (qmake or cmake or what you use) and possibly create a Debian package on top of that. The Qt Creator is unlikely to help you with these.

Turn off XP Theme in VS2008 compiled MFC App

We've just recently switched our C++ MFC Application from VS2005 to VS2008. Unfortunately in doing so our UI has appearance problems, with things like group boxes appearing blue rather than black, properties dialogs having a white background etc. I presume that in VS2008, MFC has been changed to respect the OS theme (in my case XP default theme). Unfortunately, changing all our controls and our custom toolbars to make the app look decent again is going to require a lot of work.
So, does anyone know if there is a way in code to put the app back in VS2005 mode? I found the following code
typedef void (WINAPI *tSetThemeAppProperties)( DWORD );
tSetThemeAppProperties pSetThemeAppProperties=0;
HINSTANCE handle = ::LoadLibrary("UxTheme.dll");
if (handle)
pSetThemeAppProperties = (tSetThemeAppProperties) ::GetProcAddress(handle,"SetThemeAppProperties");
if ( pSetThemeAppProperties)
{
// call function
pSetThemeAppProperties(0/*dwFlags*/);
}
::FreeLibrary(handle);
Which does stop the XP theme being picked up, but turns off ALL themes and leaves the application looking more dated than it did in VS2005.
thanks
It may be that VS2008 is including a Manifest file in the project that loads the version 6.0 comctl32.dll rather than the 5.82 comctl32.dll... both ship with Windows XP and newer.
Under "Properties->Configuration Properties->Linker->Manifest File", set the "Generate Manifest" option to "No".
Then add your own manifest file if you like, and set it under "Properties->Configuration Properties->Manifest Tool->Input and Output", "Input Resource Manifest".
Just make sure that if you add your own manifest file that it doesn't contain the reference to commctl32 v6.