Where to put the qt5 resource files after building an executable? - visual-studio

I developed a Qt5 application for Windows on Visual Studio. I installed Qt Visual Studio addin, and add resource files using Qt resource editor. It works when I execute my program by clicking Start Debugging button. However, when I try to start the program by clicking the .exe file, all the icons are missing. Where should I put the resource files?

The resource files are embedded in your executable. The reason for icons not showing up is something different, probably related to missing plugins (e.g. if you use .svg files you will need to deploy the respective qsvg plugins from {QTDIR}/plugins/iconengines or {QTDIR}/plugins/imageformats).
The reason why this is working when starting from Visual Studio is that it automatically adds your Qt directory to the path.

Related

How to turn visual studio files into actual app that can be sent/ downloaded and run by another user?

I have a finished project with a bunch of different winform files. They are linked between eachother through a menu file. How do I go from having this project as a visual studio application file to an actual application, with customized icon and that can be opened by a user from another PC (which doesn't have Visual studio). I don't want to just zip them.
I didn't try anything and this might be a newbie question but what I expect is basically to have an actual app instead of a bunch of files.
When you compile the winforms project you get a bin folder and a Debug/Release folders inside.
A simple way to deliver the app is just copy the Debug folder that have the .exe and dll files to the dest PC.
The best way is to follow this guide:
https://learn.microsoft.com/en-us/visualstudio/deployment/quickstart-deploy-using-clickonce-folder?view=vs-2022
Or make an autoinstaller

Visual Studio Advanced Installer Extension - how to package app.config files in console app

I am using the Advanced installer extension in Visual Studio 2019 to package a console application. It works fine except that it does not package/install any of the .config files (such as myexe.exe.config).
Does anyone know how to get it to do this? The console application has transforms using SlowCheetah and on build places them correctly into the bin// directory.
I would expect these files to be listed as 'primary content' and exist.
You can manually add (one-time operation) the .config file in your setup project using the [Edit in Advanced Installer] button. Have a look on their video tutorial.

Qt5VSAddin for Visual Studio 2013 - where are the Settings saved to? And/or how to disable addin?

I'm working with Visual Studio 2013 professional and Qt 5, so I installed Qt5VSAddin, which is working as intended (I can choose an installed Qt version; meta compiling etc is working; Creating new VS Qt project works like a charm).
However I would like to use the same project and solution files on different machines, where Qt isn't necessarily installed in the same directory.
At the moment, the Qt addin changes the content of the project's .vcxproj.user file and adds the line <QTDIR>directorypath</QTDIR> with "directorypath" being the path I've chosen in QT5->"Qt options"->"Qt versions" of the addin. So if I compile on that machine, QTDIR in the .user is changed to that machine's Qt installation directory, meaning that I'll destroy the project file for anyone else trying to compile the project on another machine (maybe someone without the addin).
What I want to do is to change this Qt version information to a path relative to an environmental variable, like <QTDIR>$(MY_QTDIR)</QTDIR> or <QTDIR>$(MY_DEV_ENVIRONMENT)/Qt/</QTDIR>. Unfortunately, Qt5VSAddin does not allow to create QT versions with environmental variables (at least not with $() syntax) because it does not let you click on the "OK" button in this case.
I tried to change it in the .vcxproj.user file direcly, which does work (I can compile the project this way on another machine without the addin), but on VS2013 restart or clean->build it will overwrite the changes again.
I tried to deactivate the Qt5VSAddin in extras->add-in-manager (unchecked all 3 boxes) but after VS restart, the addin is active again. How can I deactivate it completely without uninstalling (I would still like to create new Qt projects with the addin occasionally)
Is there a way to set the Qt version path of the Qt5VSAddin including an environmental variable?
If not from the GUI, maybe I can change it directly in some config file? unfortunately I couldn't find the file/location where the addin configuration parameters are placed. So where are those pathes and settings saved to?!?
Addin stores its settings and Qt paths in registry: HKCU\Software\Digia\Qt5VS2013\ and HKCU\Software\Digia\Versions\ accordingly.
I didn't find yet where those settings are placed.
I tried to create a fantasy-named-folder and search for that foldername within all files on my drive, but didn't find it...
However I found the reason why I could not deactivate the Qt5 addin in Visual Studio for longer than the current session:
Visual Studio has to be started as Administrator to change the Addin options (at least for the Qt5 Addin) persistently!
After deactivating the addin, everything works as I like it.
I'm still interested in finding and manipulating the Qt-Versions pathes of the addin, since accessing the new project->Qt5 Projects templates, without re-activating the addin, results in a broken/incomplete project. So to get a working new Qt project, atm I have to restart VS as admin, activate the addin and create the project there (followed by manually editing ther .user file and deactivating the addin as admin again)...
UPDATE: Unchecking only the "start" addin option as an admin, I can activate the addin for non-admins on-the-fly to create a new project. I think I will be able to work this way, however I'm still interested in the second question.

Visual Studio "Open as a Web Site" context menu option

Microsoft WebMatrix comes with an awesome Windows Explorer context menu option that allows you to open a folder as a website project. Are there any extensions or scripts I can use to add a similar option to do the same with Visual Studio?
I found a small project that does just what you're asking for:
The complete code can be downloaded here. Once you have the code
downloaded and compiled, to add the “Open as Website” option to the
Windows Explorer context menu you'll need to run the .reg file
included in the download. This adds a registry entry in
HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Folder\shell\ that runs the
program, passing in the path folder of that was just right-clicked.
You will need to customize this .reg file before you run it, putting
in the path to the program. You'll also need to specify the path to
dump the project files. I chose the folder C:\Documents and
Settings\Scott\My Documents\Visual Studio
2005\Projects\TempWebsiteProjects, but any path should suffice.
Take a look here for the full instructions: http://scottonwriting.com/sowblog/archive/2005/12/05/163132.aspx

Visual Studio relative paths

I have some videofiles in our SVN repository alongside the sourcecode of my application. After checking out, the visual studio project is built using cmake.
my code needs to load the video files and it works well when running the application out of visual studio - but when the exe file in the release/debug folder is doubleclicked, it crashes because the relative paths are not right anymore. aparently when running it from within visual studio, the folder where the .sln file lies is considered the root of relative paths.
how can I refere to the videofiles from the code, such that the application works if i run it within visual studio as well as if i double click the exe in the release/bin folders, without to duplicate the videos? (they are quite big)
I need to do this because I have to hand in my application such that it can be compiled and run out of the box as well as executed without visual studio.
You can change your project's settings to make the IDE's behaviour match double-clicking on the executable, and then fix your relative paths.
For VS10/VS11, in the project's properties page, at the top select All Configurations from the Configuration: list.
Then select Configuration Properties->Debugging and set the Working Directory to $(OutDir)
Beware that running the executable from the command prompt in a directory other than $(OutDir) will still fail.

Resources