How to force qtcreator use qbs profile? - qt

I'm working with qtcreator 3.5.0 and custom build of QT 5.5.0
I want to build my project both with qbs & qtcreator.
So, I've created qbs profile, as described in qbs manual, and it works well. But I've failed to force qtcreator use this profile. It creates it's own profile, based on mine, but with different name.
e.g. `qtc_Desktop-debug` & `qtc_Desktop_0aa29aa9-debug`
The problem is that build paths includes profile names. And even if I have completed build by qbs, I need to build all the sources again from qtcreator, if I want to use it.

To copy exactly build done by QtCreator just copy command displayed in project configuration details (to make thinks easier you probably want to wrap it in script file):
BTW: QtCreator's QBS profiles are direct copies of your build Kits configuration (set in Tools > Options > Build & Run > Kits) so if you need to tune it you should do it there.

Related

How to add build steps in Qt Creator for every project?

Using Qt Creator (latest released version, "Qt Creator 5.0.3 based on Qt 5.15.2"), the default build steps when creating a new project using meson are wrong.
My project configuration is the following: I have my source code, meson build files in a directory which also contains the build directory named "build".
Here are the default build steps:
Here is what it should be:
Is there a way I can change the default build settings for every project? Can someone explain why Qt Creator doesn't have good build steps by default?
Tools > Options > Meson > Enable "Autorun meson".
Yeah, that's an easy fix.

Cannot find c:\Users\qt\work\install\lib\Qt5Widgetsd.lib when compiling QtWebEngine examples

I downloaded Qt5.6 VS2013 32bit and try to run the official example of QtWebEngine.
I just followed the instruction but
When linking it gives out an error of
LNK1104 file not found c:\Users\qt\work\install\lib\Qt5Widgetsd.lib.
However, I have no idea of where this path c:\Users\qt\work\install\lib\ comes from.
I did text search in all directories of example folder and no hits other than generated files(makefiles and pdbs).
I also checked system environment variables but no hits.
Furthermore, I checked Qt Creator'r Projects panel and its Build Environment and still no hits.
Did I miss something?
P.S. this error was given out by linking DemoBrowser example of QtWebEngineWidgets pro
The link is generated by qmake when it generates the build scrip from the qt project file (*.pro). It is based from the qmake application path that is generaly installed together with the libraries (check you qt kit setup to change it if needed: Jst browse to qmake.exe application).
Then try regenerate the build script. It should fix the issue.
You may also have issue with installation not being in debug mode; you are trying to use Qt5Widgetsd.lib library instead of the non-debug one Qt5Widgets.lib

Using Qt Installer Framework to create my Application Installer

I want to create an installer for my Application. So, I have read about Qt Installer Framework and I tested the tutorial example and create the installer and everything work find with the example. But I have a doubt when I try to do the same process for my Application. When I compile the code a folder is created at the same level of my code:
MyApplication (my code)
build-MyApplication-Desktop_Qt_5_4_1_MinGW_32bit-Release (code compiled)
So my questions are:
What files of the compilation do I need to copy into the folder myinstaller/packages/vendor/ recommended by Qt Intaller Framework?
If I have dependencies of Qt like serialport, multimedia, and others, how do I insert these dependecies with Qt Installer Framework?
windeployqt.exe is what you want. Just run that on the command line and give it your executable as the argument. It will automatically copy in all the required Qt libraries and even provide the runtime redistributable installer. Then you can use the binarycreator to generate an installer.
You can put all the dependencies in myinstaller/packages/vendor/data, along with your exe. and eventual additional files. I recommended using i.e. dependency walker for finding all the required dependencies. Some of the binarycreator tutorials on qt are outdated; make sure you use the command
<location-of-ifw>\binarycreator.exe -t <location-of-ifw>\installerbase.exe -p <package_directory> -c <config_directory>\<config_file> <installer_name>
with the appropriate arguments.

How can I specify different working directories in qt creator?

I'm using the latest QT SDK under Windows and am wondering how I specify a working directory based on the build type. I need a different working directory and release and debug builds of the same project. For instance, I have a run target called MyProgram and two build targets, Release and Debug. MyProgram depends on some external libraries. When I run MyProgram in debug I need it to run in the directory C:\foo\bar\libraries\debug, however when I run it in release I need it to run in directory C:\foo\bar\libraries\release. It would appear that the Working Directory is only dependent on the run target and not on the build target. Is there a way to specify a Working Directory based on both run and build target? Could I use a variable to specify release/debug in the Working Directory?
Yes, you can. Delete the .pro.user file in the project directory, open the project, and set "Create build configurations" to manually, and check "Use shadow building". Now you can specify the target directories.
BTW, for a better solution for your missing libs, check out the Qt resource system: http://developer.qt.nokia.com/doc/qt-4.8/QResource.html

Qt when building Qt from source how do I clean old configure configurations?

I'm compiling Qt from source, but I don't want to extract the source each time I want to build it.
How can I clean previous configuration with the configure tool?
For Qt4 and earlier, try this:
nmake confclean
You can then re-configure and re-compile QT.
As noted in the comments, this no longer works in QT 5. This is due to the fact that the Qt project now uses separate sub-modules for different parts. If you have a local clone of the Qt git repos, you can try calling this from the main Qt directory:
git submodule foreach --recursive "git clean -dfx"
As noted here, there may be some problems if you have a downloaded source archive. The link I posted suggests using a shadow build instead so the process of making a clean configuration is as simple as configuring to build at a new shadow build destination.
As of today (Qt 5.9.0 beta2) there is no confclean target in Linux, and you need to manually remove .config.cache file to reconfigure.
Note that make distclean doesn't help at all.
For the latest versions, use a shadow build, then you can just nuke your directory. My batch file for configuring effectively creates a new folder, moves into it, then calls configure.
Then you just go into the shadow directory and run 'jom'.
When you want to make a different configuration, just use a different shadow directory.
This effectively means that your source tree doesn't get filled with build artifacts, which are impossible to remove when you want a different configuration. Trust me, this is the thing to do....
mkdir shadow_dir
cd shadow_dir
%~dp0\src\configure.bat ....
On Ubuntu:
make confclean
BTW, the following text displayed after run configure:
Qt is now configured for building. Just run 'make'.
Once everything is built, you must run 'make install'.
Qt will be installed into /home/ben/qt/qt-everywhere-opensource-4.7.4-debug
To reconfigure, run 'make confclean' and 'configure'.

Resources