How to compile with Qt Creator - qt

I'm trying to compile this source with Qt Creator: QPropertyEditor
What I do is just clone the repo, double click the .pro file:
Then I right click in the project, and build:
I'm getting this errors:
I've checked the output directory and I guess it's correct: %{Config:DefaultProjectDirectory}
I don't know what to do now, I only used Visual Studio, it's my first time with Qt and I can't find anywhere the option to build debug files, etc

Related

Why does a build of a qmake project fail with 'qglobal.h': No such file or directory?

I'm trying to release-build a qmake-based, Qt-using project (Qt Creator) as follows, starting from a clean command prompt:
"%ProgramFiles(x86)%\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" x86
cd build
\qt\5.7.0-shared\bin\qmake.exe "CONFIG=release" \qt\qt-creator-opensource-src-4.1.0
nmake
Output:
[...]fatal error C1083: Cannot open include file: 'qglobal.h': No such file or directory
This is perfectly reproducible on every machine I've tried it on, across multiple Qt versions. The choice of a project doesn't matter: it could be a trivial one.
The CONFIG qmake variable holds a list of default values. One of those is QT. By assigning to it, the defaults are overriden. Thus QT is removed from the configuration, and the build does not to depend on Qt. Thus no Qt includes are found.
Instead, one must append the value to CONFIG:
qmake "CONFIG+=release" [...]

QT building project -- static build

I am new to QT. I have just installed Qt 4.7.4 (32 bit) which uses mingw compiler. I have few questions.
Please try to answer these :--
I have created a gui application in QT creator. With build configuration For each QT version one debug & one release now it created a build folder geny-build-desktop-Qt_4_8_1_for_Desktop_-MinGW_Qt_SDK__Debug
Inside this folder three makefiles are there :---
Makefile
Makefile.Debug
Makefile.Release
Inside this folder two folder are there :---
debug ---> contains compiled .exe file
release ---> empty
Q-1> How can I change settings in QT creator to compile my project for the release build ?
On the left toolbar of Qt Creator you will find the button to set the build for your project, set it to release.
With your settings a folder named geny-build-desktop-Qt_4_8_1_for_Desktop_-MinGW_Qt_SDK__Release will be created with a release subfolder in it, containing your compiled binary.
Anyway, it doesn't have to do with static build, it is simply a release build of your binary, still depending on Qt dynamic libraries. The difference is that the debug build is linked to the debug libraries (for example: Qt5Cored.dll), while the release build is linked to the release libraries (for example: Qt5Core.dll).
Release builds are usually optimized and don't include debug symbols, so they are also smaller.
If you think about static linking Qt to your program (i.e. getting a binary which not depends on Qt dynamic libraries) you should be aware that you should get a commercial license.
Try using the CTRL + T combination.

Qt creator: where can I find the debugging symbols within my project?

I am trying to understand 'qmake' by following this tutorial . However, when I run my .pro file WITHOUT using CONFIG += debug and then WITH it (to add the debugging symbols), I see no difference. I want to see these debugging symbols, where exactly I can find them within my project ?
I want to see how they can help me as a developer ?
They should show up in the build directory specified in your project settings in Qt Creator.
With MSVC2010, it creates a pdb file in <Project>/debug when using Qt Creator.
Here is the qmake line:
qmake.exe "C:\path\to\myproject\myproject.pro" -r -spec win32-msvc2010
Which is probably getting executed in:
"C:\path\to\myproject\debug"
or if you are using shadow building enabled in Qt Creator, it will end up in:
"C:\path\to\myproject-build-VS2010-<QT_VERSION>__Debug"
http://qt-project.org/doc/qt-5.0/qtdoc/qmake-manual.html
Hope that helps.

Qt SUBDIRS project not finding executable to debug

I've decided to move all my projects (multiple DLLs and an executable) into a SUBDIRS project to make building easier. While this has let me build everything into a single folder, I can no longer debug from Qt Creator.
My folder structure is as follows:
Solution.pro
\MyDLL1
\MyDLL2
\MyDLL3
\MyDLL4
\MyExecutable
\OUT
I have all DLLs and my exe building into OUT (via DESTDIR in each project's .pro) - same level as the subdirs .pro. When attempting to debug, I get the following:
No executable specified.
Debugging has finished
I've tried modifying the project Run settings to directly point to \OUT\MyExecutable.exe, I've tried adding a DESTDIR to solution.pro pointing to OUT, but nothing so far as worked.
Is my setup completely wrong? Or am I missing one small piece to let Qt run the .exe to debug?
Edit:
I tried filling out my Run settings again: here is my Run setup via the Projects options, and the resulting message. The exe never actually gets launched. I am, however, able to Run the project with this setup, just not debug. I have verified the exe is not being launched by putting a breakpoint at the start of int main() within main.cpp in the executable's project. ,
Debugging starts
Debugging has finished
It appears updating Qt (both the Creator and Compiler) has resolved this issue.

Installing Qt Quick Components for Desktop for use with Qt Creator

I'm trying to use Qt Quick Components for Desktop from http://labs.qt.nokia.com/2011/03/10/qml-components-for-desktop/
I can build and install it just fine into it's own folder, and view the qmls with qmlviewer, but how do I use these qml components from my other projects in Qt Creator?
For example, I'd like to be able to use Dial.qml from the Qt Quick Components for Desktop to make a Dial element in a qml file in my project.
I used the instructions from the answer for this question: Qt How to make and install plugins? and was able to successfully use the qt quick desktop components within qt creator qml files. Here are more detailed instructions that I made:
Download the tar.gz from http://qt.gitorious.org/qt-components/desktop/trees/master
Extract the components anywhere (e.g. C:\qt-components-desktop).
Open command prompt.
run vcvars32.bat from "your Visual Studio"\VC\bin\ directory ... (usually C:\Program Files\Microsoft Visual Studio 9.0\VC\bin) in command prompt.
e.g. "C:\Program Files\Microsoft Visual Studio 9.0\VC\bin\vcvars32.bat"
You should receive a message similar to: "Setting environment for using Microsoft Visual Studio 2008 x86 tools"
Set command prompt to use Qt Creator's bin path ... (usually C:\Qt\qtcreator-2.1.0\bin).
e.g. SET PATH=%PATH%;C:\Qt\qtcreator-2.1.0\bin
Set command prompt to use Qt's bin path ... (usually C:\Qt\4.7.2\bin).
e.g. SET PATH=%PATH%;C:\Qt\4.7.2\bin
Navigate in command prompt to the folder where you extracted the qt desktop components.
Run the following commands:
qmake
jom debug
jom install
Copy the "components" folder from where you extracted the qt desktop components.
Place it in "your Qt directory"\imports\Qt\labs ... (usually C:\Qt\4.7.2\imports\Qt\labs)
Open the qmldir file inside the components folder in any text editor and observe the version number on each line (e.g. 0.1)
Place the following import statement in any qml file to use Qt desktop components:
import Qt.labs.components #.#
where #.# is your version number (e.g. 0.1)
Download the tar.gz from http://qt.gitorious.org/qt-components/desktop/trees/master
unpack
launch vcvars32.bat, then go to qt-components-desktop\ folder
go to qt-components-desktop\components\ folder (cd components), type "qmake && nmake install"
go to qt-components-desktop\src\ folder, type "qmake && nmake install"
These are alternative steps using a windows system and mingw which comes with Qt. For this example, I installed the Qt SDK to C:\QtSDK. For these instructions, I used Qt 4.8.1.
Download the tar.gz from http://qt.gitorious.org/qt-components/desktop/trees/master
Unpack the components
Add Qt's Desktop mingw bin path and Qt's mingw bin path to the PATH system variable with one of the two options:
Option 1: (persistent) Using the control panel. (http://www.computerhope.com/issues/ch000549.htm)
Navigate to "Control Panel" -> "System" -> "Advanced system settings"
Select the "Advanced" tab
Press the "Environment Variables..." button, located below the third groupbox and above the OK/Cancel button
Under the "System variables" groupbox, scroll through the list and find the "Path" variable
Double click or select the "Path" variable and press "Edit..."
Go to the right-most end of the "Variable value:" field by either clicking within the field and pressing END on your keyboard or scrolling to the end with your mouse.
Add a semicolon ; then the path to Qt's mingw bin directory, in this case it is C:\QtSDK\mingw\bin
Add another semicolon to the end and then Qt's Desktop mingw bin directory located in the version of Qt you are using, in this case it is 4.8.1: ;C:\QtSDK\Desktop\Qt\4.8.1\mingw\bin
In the end, the addition to the path variable should look like this: ;C:\QtSDK\mingw\bin;C:\QtSDK\Desktop\Qt\4.8.1\mingw\bin. Note that these paths could also be added anywhere and whichever order within the path variable.
Press "OK" to all opened windows to close and save your changes.
Option 2: (temporary) Using the SET command. This method only lasts within the command prompt window it was executed. If the command prompt window is closed, the SET commands must be re-entered.
Add Qt's Desktop mingw bin directory with SET PATH=%PATH%;C:\QtSDK\Desktop\Qt\4.8.1\mingw\bin
Add Qt's mingw bin directory with SET PATH=%PATH%;C:\QtSDK\mingw\bin
Continue the steps below with this same command prompt window. The SET commands are only set for the specific command prompt window you executed them in.
If option 1 was used, open a new command prompt and navigate to where the qt desktop components are extracted. If option 2 was used, use the same command prompt to navigate to the qt desktop components folder
Run the following command: qmake && mingw-make install
This command will automatically copy the compiled component files to C:\QtSDK\Desktop\Qt\4.8.1\mingw\imports\QtDesktop so there is no need to manually move or create any folders.
Make a new Qt Desktop project, and select the mingw which matches the Qt version as the toolchain.
Attempt to compile and run the following code:
import QtQuick 1.1
import QtDesktop 0.1
Rectangle {
width: 100
height: 100
Button {
id: button
text: "Push me"
onClicked: button.text = "Pressed"
}
}
Done
At the time of these instructions, the latest version of the QtDesktop components is 0.1. To check the version you installed, navigate to C:\QtSDK\Desktop\Qt\4.8.1\mingw\imports\QtDesktop and open the file qmldir with a text editor and notice the version number on each line.

Resources