How to get .pro file from the set of qt files - qt

I was trying to modify the source code of this open source project https://github.com/haiwen/seafile-client
As I can see it contains .ui, .qrc etc files which is used in Qt, but there is no .pro files present in his repository. So how to get the .pro file for this repository code. Any idea?

That was the Cmake project , you should install CMake in your system and build it like this :
cmake .
make
make install
OR use CMakeLists.txt instead of .pro .

You can use qmake to generate the .pro file for this repository.
Just do the following steps:
Clone the repo.
cd into the repo
Run the following command
qmake -project -r *
It will repeatedly look into the directory and it's sub-directory files and will generate required .pro file for you.
You can learn more about this at below given link:
https://doc.qt.io/qt-5/qmake-running.html#project-mode-options

Related

QMAKE_QMAKE with symbolic link to qmake

I need to get path of folder with my qt in pro file.
I used QMAKE_QMAKE and everything worked.
But now I created a symbolic link to qmake in ~/.local/bin to make it easier to call qmake.
qmake-linux -> /home/andrei/Qt/Qt-v5.13.0/Linux/bin/qmake*
And now I ran into the problem that qmake, launched by a symbolic link, contains in the variable QMAKE_QMAKE not the path to the executable file, but the path to the symbolic link.
Info: creating stash file /home/andrei/worker/githubworker/github-worker/build/.qmake.stash
Project MESSAGE: QT_DIR = /home/andrei/.local/bin
Maybe it is important: I build qt from sources.
Maybe there are ways to get qmake paths or folders with qt?
The directory where the qmake executable is located can be retrieved with $$[QT_HOST_BINS]. This is a qmake property.
Call qmake -query to see a list of available properties.

Get a .pro file from a Makefile

I have a project that generates a Makefile by using a custom script.
I would like to import this project into Qt Creator but in a way that I can add new files and compile them automatically (without manually editing the Makefile every time).
To simplify, i need a .pro file that would create a currently available Makefile.
Is there a smarter way to do it but to manually check the dependencies for each source file and add them to the .pro file?
qmake -project
should create the project file. Then use the "Add new file..." from Qt Creator to maintain the .pro file automatically.

Set Additional Include Directories in Qt Creator

I am using Qt Creator to rewrite my former project which is developed in Visual Studio. In this project I need to use an external library (gloox for xmpp).
Here's what I did in Visual Studio:
Add c:/dir1/ to the Additional Include Directories, that's where the tons of .h and .cpp files are.
Add c:/dir2/ in the linker setting, that's where the .lib file is.
I want to do the same thing in Qt Creator, so I added INCLUDEPATH += c:/dir1/ to the end of my .pro file, but when I qmaked again I still could not include anything from dir1 successfully.
#include <message.h>
C1083: Cannot open include file: 'message.h': No such file or directory
What should I do?
Based on the comment discussion, the problem seems to be that, after the INCLUDEPATH and potentially other relevant modifications, you forgot to properly re-run qmake.
This is necessary when dealing with QtCreator unfortunately due to the following long-standing issue:
Creator should know when to rerun qmake
I found the solution: copy everything in the .pro file and delete the .pro file. Then create a new .pro file and copy everything back, then execute qmake then run.

How to build and run a Qt application from the Windows command line?

I'm trying to create a simple Qt project. I have done inside of a folder the following:
Created a .ui file
ran qmake -project
Made a .pro file
Made a main.cpp file
How can I run this project using a command line?
You probably should run qmake to generate a Makefile from your .pro, then run make to compile and build the executable binary program, then run that program by its name. You might need to type the full or relative file path of the program if your PATH is not containing the directory having the program binary.

CMake + Qt : define the moc/ui output directory

I'm currently transferring a project built with qmake to CMake.
In the version with qmake, in the .pri file, there was
MOC_DIR = .moc/$${PLATFORM_NAME}
that permitted to produce the MOC temporary files in a given directory, keeping the sources clean. How to do the same thing with CMake?
Note: with CMake, I use the FindQt4.cmake package and the command QT4_WRAP_CPP().
As baysmith says, if your goal is to keep your source directory clean, the real solution is to use CMake's "out-of-source" builds feature. If you're on Windows, set "Where to build the binaries" to a new directory, different from the "Where is the source code" directory. If you're on Unix, it goes something like this:
cd <source directory>
mkdir build
cd build
cmake ..
make
By running CMake on a different directory, all of the build files will go into that directory, and your sources will stay clean. (Note: the build directory doesn't have to be inside the source directory. See the CMake wiki for more details.)
If "out-of-source" doesn't work for you, I was able to find one other option. Based on what I can tell from the Qt4Macros.cmake file installed with my CMake 2.8, it isn't accessible as a config parameter. Here's the relevant line:
SET(_moc ${CMAKE_CURRENT_BINARY_DIR}/${_current_MOC})
The workaround is to change all of your MOC include directives to specify the subfolder you'd like to build to.
#include "moc/mainwindow.moc"
After creating the moc directory inside my build directory, there were no problems building, and my MOC file was in the new directory.

Resources