Opening Qt Project After Relocating It - c++

I created a C++ Qt Creator CMake project. It worked perfectly when I loaded in to the program. However, when I copy pasted the project into another folder, it doesn't open in the Qt creator application anymore.
Instead of a Qt project, it just opens as a normal folder with CMakeLists.txt only while all other files are added separately. Is there no way I can copy the program as it is?

Remove CMakeLists.txt.user when copying it to another folder. Then QtCreator will not open the old settings and creates a new build tree.

Related

Qt application release exe not running

I have built a very simple calculator in Qt. When I run it in release mode from qt creator, everything works fine. However when I go to the release folder and run it, it gives QT5Core.dll, QT5Widgets.dll and QT5Gui.dll not found. After running windeployqt there by:
windeployqt .
All the dll get added. However, it then gives error VCRUNTIME140_APP.dll and MSVCP140_APP.dll not found. After copying them to the folder. The exe doesn't give any error on double clicking but just does not start. What should I do?
I found this solution here, however I cannot find any qml file in the application directory.
I created it as a QT widget application. I am using Windows 10 with Visual Studio 2017 and MSVC2017 64bit desktop kit. The application is in C++.
Update:
Running the command
windeployqt Calculator.exe
after adding qt to the path seems to do the trick. Application working even after removing qt from the path. Will try running the app inside vm just to be extra sure.
When running from the command line, add your Qt Bin directory to the PATH. For example:
C:\> PATH=C:\Qt\Qt5.11.0\5.11.0\msvc2017_64\bin;%PATH%
You can solve the problem as selbie described it. An another way is to copy the missing .dll-Files to the folder where the.exe is placed.
See here https://doc.qt.io/Qt-5/windows-deployment.html#creating-the-application-package :
To deploy the application, we must make sure that we copy the relevant Qt DLLs (corresponding to the Qt modules used in the application) and the Windows platform plugin, qwindows.dll, as well as the executable to the same directory tree in the release subdirectory.
set variable VCINSTALLDIR, example:
set VCINSTALLDIR=p:\Programs\Microsoft Visual Studio\2017\Community\VC\
and next run
windeployqt.exe app.exe
Or copy vc_redist.x64.exe from Redist subfolder into folder with your application.
As #mosa mentioned, To deploy the application, we must make sure that we copy the relevant Qt DLLs (corresponding to the Qt modules used in the application) and the Windows platform plugin, qwindows.dll, as well as the executable to the same directory tree in the release subdirectory.
To add missing .dll files first open QT MSVC Console and type windeployqt.exe command,
Then you have to go to the directory which .exe file contains. Let's assume my .exe is in the desktop,
C:/
cd user/indrajith/desktop
Then you can add missing .dll files using following command,
windeployqt.exe --quick.
Finally, just double click your .exe file to run the program.
Simple Solution:
Copy "bin" and "plugins" folders from the qt setup directory(C:\Qt\6.2.4\mingw_64) to your release folder.
Put your .exe file inside that "bin" folder and done.
Now, your .exe application should run.The bin and plugin folders contain required .dll files and unnecessary files can be removed manually.

Qt5PrintSupportd.dll is missing

I searched about that problem everywhere, i really don t know what to do.I created a notepad app, in compiler everything went fine but when i m running it external it gives me that error : The program can t start because QT5PrintSupportd.dll is missing from your computer
Edit: Everything works fine now thanks a lot guys.
For example my Qt install is inside : C:\Qt\Qt5.11.1\5.11.1\msvc2015_64\bin
Qt5PrintSupportd.dll is inside the bin folder. If you can't find the dll reinstalled Qt.
After copy this dll near to the .exe or add to system32.
For window, may be you need to add the plugin folder printsupport near to the .exe file.
You can find this folder in C:\Qtpath\plugins\printsupport
----
| app.exe
| printsupport\windowsprintersupportd.dll
The Qt command 'windeployqt' is the proper way to copy all of the needed Qt stuff to your application's directory.
PrintSupport is a standard module of Qt 5, so you should have it within your Qt's installation dir: <qt_dir>\bin\Qt5PrintSupport[d].dll.
Notice the d suffix in the filename, it indicates it is the debug version. Qt5PrintSupport.dll is for release, Qt5PrintSupportd.dll is for debug.
Now, you have to copy that DLL from your Qt's installation and paste it in the same directory as of your executable (probably you've also copied other Qt DLLs there). Again, be aware of the difference between release and debug DLLs.
Note: I would not copy it to any directory in the path but to your executable's directory. In this way you avoid future conflicts if you upgrade your Qt version.

Compiling executable from .pro

I have a folder which has some source in it, that should be ready to compile. The folder has a .pro file in it, which seems to be the compiling file, but how do I use it? I'm trying to create an .exe from it.
The *.pro file normally stands for a project in an IDE.
Since you have the resources file (.rc) it seems the project has been done in Qt Creator.
You can try to download the Qt Creator (and install it) and then by using
File -> Open File or Project
navigate to that .pro file and open it. You can then configure the project and build it.
If the project was not done in Qt, then you will need to be more specific about the problem ...

Change Qt Creator project name for CMake projects

I've imported CMake project into Qt Creator. However, its name has been set to 'Project. I can't find GUI entry to change this name to other more meaningful.
I've changed all Project entries in CMakeLists.txt.user file (created by Qt Created). In result - Qt Creator during startup finds modified file faulty and triggers again 'Import project' procedure.
How can I change project name?
You can change it adding project(your_name) (or changing it if it already exists) at the top of the file CMakeLists.txt in the root directory of the project itself.
Then open the project and run cmake from within QtCreator.
It will open the project with the right name in the project panel.

How to make .exe file in Qt Creator

I was working on Qt Creator compiler to make a simple text editor. I did that but now want to make an .exe file of that project, but I don't know how to make an .exe file in Qt Creator compiler. Can anyone help?
There is a tool that adds the .dlls automatically on windows.
In the command prompt navigate to your qt bin directory. It should look something like this: ...\Qt\5.9.1\msvc2017_64\bin\ (I'm using visual studio).
Run windeployqt.exe in the command prompt with your project location as the argument like this:
windeployqt.exe C:\project_folder\my_project.exe
Now my_project.exe will have the .dlls in the same directory and will execute.
The executable is generated by the compiler when you build your application. To know where the executable is stored, look into
Projects (CTRL+5) -> Build settings -> General -> Build directory
This is where Qt creator will put the .exe it generates if you have shadow build enabled.
If shadow build is disabled, the executable will be stored inside the project folder itself.
From:
How to create executable file for a Qt Application?
Basically you have to look for MinGW subfolder deep into Qt tree, where Qt utilities reside, and copy needed dll's.
These are the steps I follow, based upon Qt 4.7.4, for packaging the application with correct shared libraries.
Let's say you've installed Qt under c:\qtsdk.
Open your project, and compile it in release mode.
Go to this directory: C:\QtSDK\Desktop\Qt\4.7.4\mingw\bin -- it contains all shared libraries. Debug libraries end with a "d" -- frex, QtCore.dll is release version, while QtCoreD.dll is debug version.
Copy at least these files into your release directory (where your .exe lies):
mingwm10.dll
libgcc_s_dw2-1.dll
QtCore4.dll
QtGui4.dll
I just built, tested and deployed a dummy project this way.
I had the same problem so I used the suggested above answer:
"
There is a tool that adds the .dlls automatically on windows.
In the command prompt navigate to your qt bin directory. It should look something like this: ...\Qt\5.9.1\msvc2017_64\bin\ (I'm using visual studio).
Run windeployqt.exe in the command prompt with your project location as the argument like this:
windeployqt.exe C:\project_folder\my_project.exe
Now my_project.exe will have the .dlls in the same directory and will execute.
"
but there somethings that I did so this might help:
there is already an executable version of your app in the debug file of your project if you can't find it try to enter properties in Qt creator an track down the file. while you are at it in properties you can also see whether your app is using msvc2017_64 like in the previous answer or other compilers.
Take that file to the same path you write in the command line here: windeployqt.exe C:\project_folder\my_project.exe.
when your try to open the executable file it will till it needs some dlls files that you can find in this path .\Qt\5.9.1\msvc2017_64\bin copy and paste them in the location of the exe file
Steps to make an exe file from your qt project
In Build Settings make sure Edit build configuration is Release.
In Build Settings uncheck Shadow build(this will make sure that the release folder is inside of your project directory instead of outside of your project directory).
Build and run you project(This will create a release directory inside of yours project folder).
Copy *.dll and *.exe file from C:\Qt\6.3.2\mingw_64\bin to the release folder (where your projects exe file is there).
Copy all folders from C:\Qt\6.3.2\mingw_64\plugins to the release folder.
Now you can launch the exe file inside of your release folder corresponding to your project.