how to create .exe file for my Qt based app - qt

i wrote a program in Qt-Creator 1.3.1 and Qt 4.6.2
and realy dont figure out how to create a simple .exe file for the program i just wrote...
i rather do it with the Qt-Creator if it's possible

In Qt Creator, when you build (Ctrl+B) your project, it always creates a .exe that is executed when you run the app from Qt Creator (Ctrl+R or the big play button).
If you want to find this .exe, you should look in the folder where your .pro (the project file) is located in the folder debug (or release depending on your build configuration).

#Live is right. See in release or debug dir. But if you move the .exe and want to execute you will get notofications about DLL's that miss. You can find them from yout Qt installation dir. Put next to your exe file all required DLL's and you're done! The DLL files will tell your your exe file while you execute it!

Related

Qt6 qt_generate_deploy_app_script plugin DLL copying

Currently I have to manually copy the platforms and imageformats plugin folders to the directory containing the .exe that MSVC compiled. This is very tedious as the output folders often get deleted if you're working on your CMakeLists.txt or changing compilation target.
Now qt_generate_deploy_app_script seems like an official Qt solution to solve this problem, but it does not work.
I have added the CMake bits to my CMakeLists.txt as stated
qt_generate_deploy_app_script(
TARGET HiveWE
FILENAME_VARIABLE deploy_script
NO_UNSUPPORTED_PLATFORM_ERROR
)
install(SCRIPT ${deploy_script})
I can see some generated deploy scripts appear under build\x64-RelWithDebInfo\.qt, but they do not seem to be run as no DLL folders get copied to where my .exe is.
Am I misinterpreting what qt_generate_deploy_app_script should do or is it simply broken?
If you want to Creat exe in windows From Qt project you should use windeployqt
To Deploy and create Exe output with QT in windows you should follow this way:
put your compiler path in your system path. for example, if you use mingw81_64, you should set it. something like Qt/tools/mingw81_64/bin
copy exe file that provides after building in release mode in one
folder and run mingw81_64 cmd (it has separate cmd) and cd to that
folder path
windeployqt app.exe
you are using Cmake So first create one release output and then use step 3.
This command will get all dll needs for your app and your exe will work .
if you use qml
windeployqt --qmldir (the path of its directory ) app.exe
and also see these youtube videos for more info:
https://www.youtube.com/watch?v=LdSTgR0xJco
https://www.youtube.com/watch?v=hCXAgB6y8eA

How to make setWindowIcon work properly in a stand-alone executable (Qt5.14 + VS2019)?

I am programming a Qt application in MS Visual Studio Community 2019. I am trying to add an icon to my application window with the following command, and I also have the corresponding file my_icon.ico mentioned in the .qrc file:
setWindowIcon(QIcon(":/my_icon.ico"));
When I build and run my program in VS, everything is perfect - the icon replaces the standard one. However, when I make a release and try to run the resulting stand-alone executable, the icon is NOT shown! This is particularly weird as images which I also mention in the .qrc file (pictures for buttons) are on their places.
I have tried to put my_icon.ico alongside the .exe file, but with no result.
I give up, please give me a clue what might be happening here.
Thanks to chehrlic, I understood that it was as simple as running the windeployqt.exe on the .exe file build by the Release configuration by Visual Studio.
This will link all required libraries dynamically.
Avoid using this tool while the .exe file is inside the Release folder as it will create many other files & folders near .exe file. I have copied my_app.exe to a fresh directory and ran the following command from it:
C:\Qt\5.14.1\msvc2017_64\bin\windeployqt.exe my_app.exe --release
See https://doc.qt.io/qt-5/windows-deployment.html for more details.

mt.exe in Qt StandAlone .exe

I finally built a static version of Qt 5.1.1 using microsoft visual studio. I created my .exe standalone file using this code:
qmake Hello.pro
nmake release
cd release
mt.exe -manifest Hello.exe.manifest -outputresource: Hello.exe;1
what is mt.exe and what does the last line do with the "Hello.exe" file?
You could just use CONFIG += embed_manifest_exe though, but in essence you need to put the manifest file beside your executable and the last line seems to take care of that.
That is, it is adding a manifest to your "Hello.exe" executable file.
If you do not happen to know what manifest files are, then you can read the MSDN documentation below, but in short: they are carrying run time information for your executable in this particular case:
http://msdn.microsoft.com/en-us/library/aa374191(v=vs.85).aspx

Qt Creator could not find the executable, please specify one

I'm trying to run the texteditor.pro file in the QtSDK\Examples\4.7\tutorials\gettingStarted\gsQml directory with Qt Creator. When I try to build the project I get a window that says
Could Not find the executable, please specify one
with three fields to load files. Snapshot of the dialog box.
I'm running windows 7 64bit, with Qt Creator 2.4.1
I've solved the problem it was a missing dll file, but the executable didn't ask for it, so I put all the dlls from Qtcreator -> bin in the same folder with the *.exe file, then I deleted file after another until I figured out what files are required.
* It is a brute force way, but It did the job.
* Here is the file that were missing (libEGL.dll)
This project is not created in the normal 'Qt-executable' kind format. Rather its a 'plugin' kind project. So you cant run it directly like other projects.
[If you will open the project files you wont find a main() function!, which is supposed to be the entrance point usually for a C++ Application. All you have are a couple C++ classes. Take that as a hint]
About this example they have given the complete details here. And I quote:
We need to compile the file dialog C++ plugin before the text editor
can run. To compile, enter the gsQml directory, then run qmake and
compile using make or nmake, depending on your platform. To run,
launch qmlviewer and open the texteditor.qml file.
Else:
You create your own project.
Add these class files and the respective qml files to this project.
Add a main and create the respective objects required.
Make an application viewer and give "texteditor.qml" path as its source.
I had the could not find executable window pop up in my face in Ubuntu 12.10.
Here's how I got the "error":
Created a folder named Project;
Inside it, I ran "qmake -project" and then "qmake";
Created a main.cpp file inside the folder;
Opened the Project.pro file with Qt Creator and added the line "SOURCES += main.cpp" to it;
Pressed Ctrl + R to build and run the project.
Later on I deleted the folder and created it again, but this time creating a main.cpp file before trying to run any commands. I opened the .pro file with Qt Creator, created a main function in the main.cpp file, and pressed Ctrl + R, and it built and ran!

moving Qt directory

I'm working on a Qt4.7.3 project on mac osX (with xCode). I would like to move my Qt directory (installed with Qt installer). The problem is that some Qt executable files have hardcoded paths. I've already recompiled Qmake specifying the new Qt directory. So the project now compile and link perfectly, but at run time it cannot find the qt libraries (it still look into my old Qt directory). Is there other harcoded path somewhere, other configuration files to edit?
By the way, the reason why I want to move my Qt directory is to allow to share qt files via revision control tool.
The pre-built installer actually puts all the framework files into the system location (/Library/Framworks/) and you will have a hard time moving those.
Your best bet is to build it from source and specify a different install location. ./configure -help will show you how. (Use the -prefix option)
Hard links could be a way to go in this kind of situation I guess.
Try this.
Create qt.conf file in the same folder as your qmake.exe file.
[Paths]
Prefix = E:/Qt/4.8.3
Follow this link for detail description.
http://richardt.name/blog/moving-a-qt-installation-directory/

Resources