Adding Qt Sources to QtCreator 2.4.1 - qt

I am currently using QtCreator 2.4.1 with Qt 4.7.4 development libraries (in Ubuntu) and am trying to track down a bug which after profiling with valgrind seems to occur internally within QGraphicsView::paintEvent(…) method
To help isolate this problem I would like to step into the Qt sources. Having done some searching through both the Qt forums and stack overflow and have not being able to find a way to integrate the sources with my version of QtCreator.
I have currently tried downloading the sources via the QtSDK manager and adding a “Source Path Mapping” within Tools->Options->Debugger. I am sure that this step is where I am making a mistake as I am unable to even switch to source when viewing internal Qt header files i.e. from QGraphicsView.h
I have so far tried adding the following Source Path Mappings
Source Path=/var/tmp/qt-src
TargetPath=/home/paul/QtSDK/QtSources/4.7.4
and
Source Path=/var/tmp/qt-src
TargetPath=/home/paul/QtSDK/QtSources/4.7.4/src
Neither works.
I have also tried building Qt directly from source, adding this to my "Qt versions" list within Qt Creator and creating a new project configuration using this version. This also did not work.
Likewise I have tried adding the src folders to my gdbinit file. This also fails to work.
I am completely lost with this.
Paul

Someone asked a similar question here: Need to step into Qt sources (my IDE is Qt Creator).
Someone else asked about Valgrind errors with Qt here: Suppression files for Qt memory leaks with Valgrind
And here is a little more info about Using Valgrind with Qt Creator along with some explanation about how to read the results. Its a little dated from late 2010.
Related Suggestions
I wouldn't debug the QGraphicsView class just because of all the effort to make it work or find the problem might be for nothing... Qt is moving to using the SceneGraph as the backend for QML and the rendering engine for QGraphicsView might become obsolete.
Updating to the latest stable build of the Qt libraries may make a big difference for QGraphicsView.
If you post the valgrind error you are getting to the Qt Trolls, someone might be able to explain what is going on for you.
There are other debugging techniques besides the traditional debugger. I've been programming in Qt in Windows (without valgrind) and with a large multi-threaded application, that loads a bunch of Dll's. I've had to put some faith into the Object Tree Model clean up and work on all the new calls I put in. Most of the time I just use QDebug to find errors. Then I am also using a combination of qInstallMessageHandler() with QDebug to implement decent logging for the hard to track bugs.
See also Qt Debugging Techniques.

Related

QT application on BeagleboneBlack

Hi I have a debian image on BBB I have already installed QT creator on B^3 but the problem is whenever I try to start a new project in qt creator, couldn't see any option of kit. Infact when i add qmake and compiler path the application throws error.
What can I do to solve the problem. Can i directly get the full pack of SDK from qt.io/download ?
You must compile Qt libraries for your device (BBB) on your own, using specified compiler. You can find more information on this topic, here:
Qt Cross-Compilation Options
As soon as you compile Qt libraries for your device, you must move them to appropriate directories (on your BBB).
First, I would suggest learning to cross-compile, it's much faster & more easily maintained when you want to move to new versions. There's a ton of documentation and community around doing this. Windows & Linux both of which are probably dated, but info is still relavent. I've heard it's much easier from a linux host, but that could be biased.
That being said, if you don't want to cross-compile I believe you can simply install the qt embedded libraries. This question may offer some good advice. Once you have the libraries installed, you should be able to use qmake directly to create the Makefile for your project, then you can use cmake, or g++, etc.. to do the actual compiling.
You're likely going to work in command line though, I'm not sure you can run QT Creator on the BBB directly. I could be wrong.

Qt 5 and C++11 (qobjectdefs_impl.h won't compile)

NB: I have tried asking this question here (on the Qt Project forums), but to no avail for the moment, so I'm trying my luck here.
I’m using Qt 5.0.1 (on a laptop with Ubuntu 13.04), the compiler is gcc 4.7.3 (and I'm working with Qt Creator 2.7.0).
In order to have C++11 working, it seems that simply adding the following line to the .pro file of the project does the trick (or at least it's supposed to):
CONFIG += c++11
However, when I do that, I get a ton of errors in the file qobjectdefs_impl.h upon compilation.
Anyone know how to fix this problem? Thanks in advance!
Edit: Here is a screenshot so that you can see what the errors look like (apparently the errors happen when I do #include <QColor>):
NB: link to the image if it shows too small here.
Edit: I still have the errors after having upgraded to gcc 4.8.1 and Qt 5.1.2, which I compiled from the sources.
Yay, someone (JKSH) found what the problem was on Qt Project forums (here).
In short:
The problem was that I had written somewhere #define I complex(0.0, 1.0), which created a name clash in qobjectdefs_impl.h (where complex was a typedef for std::complex<double>). For some (weird) reason that didn’t cause any problems as long as I didn’t write CONFIG = c+11 in the pro file, but not it did after writing it.
Many thanks to JKSH, and also Greenflow for helping!
Edit: The credit for finding the issue should go to Thiago Macieira from the Qt Project Interest mailing list, see comment.

How to use QtCopyDialog?

I include this library:
#include <QtCopyDialog>
When i compile, i see this error
"QtCopyDialog: No such file or directory"
How to solve this problem?
Thanks.
QtCopyDialog is not part of the core Qt library, but was released as part of Qt Solutions, a now discontinued add-on. The official Qt site links to a newish Git repository containing a few of the original Qt Solutions classes. This appears to be the most (only?) maintained location for the Qt Solutions source, but QtCopyDialog appears not to have made the grade. The only place I can find the source for QtCopyDialog is here. Judging from the docs, the last time it was maintained was pre Qt 4.5. You might need to make some changes in order to get it to work with whatever version of the Qt libs you're using.

Is there a way to run Qt Creator from command line supplying a .pro file to open (or how do we deal with multiple Qt installations)?

I have multiple installations of Qt4 on my Windows XP SP2 machine and have installed Qt Creator 2.1 today. However, running the project (.pro) files spawns the oldest version of Qt Designer installed (the one installed in 2009 together with the rest of the framework).
Since
I would not like to remove any previous installations of Qt
and for some obscure reason even if I explicitly ask Windows Explorer to always use the version I need it does not
I would like to give up a bit and just sript the needed behaviour in a .bat file like:
e:\path\to\qtcreator.exe %1
This opens Qt Creator, but something seems to prevent it from treating the .pro file properly (in short, the project does not "open" as it should).
Qt documents have a page on the matter at Qt Creator: Using Command Line Options, but it seems to ignore the topic in question.
Since Qt (being as excellent framework as it is) is also known to have its quirks (like that of qmake), I wonder, may be there is an undocumented way to solve my problem?
(Another way to fix the thing would of course be to make the correct version of Qt Designer run, but frankly I'd prefer the "hard-wired" solution since the mechanisms provided by Qt itself are still a bit unreliable.)
The libraries and tools used for a particular project (and a configuration in it) is set in the Projects panel in Qt Creator:
http://doc.qt.io/qtcreator/creator-build-settings.html
Selecting the Qt version to use with a project should force it to run the Designer that's part of the version. If it doesn't, then you should report it as a bug.

Linking Application to static version of QT

I'm new to QT and I've been trying to compile a static build of QT of DAYS (literally) I'm pretty much out of Ideas and the QT documentation is probably the least helpful I have ever read. It doesn't work out of the box thats the problem. It needs to be tweaked a considerable amount before you can compile it as static. Finally the other night I managed to compile it statically and then followed the instructions to deploy it. I then copied the executable to another machine where it promptly complained for the lack of dll msvcp100. WTF! I thought that the static build was dependency free! Can you guys give me a definitive answer that can solve my problems?
That's the Visual C++ runtime library, not QT. You need to install http://www.microsoft.com/downloads/details.aspx?FamilyID=a7b7a05e-6de6-4d3a-a423-37bf0912db84&displaylang=en

Resources