How to view QString values in debugger with Qt 5.5.1 - qt

Does anyone know how to view QString values in the debugger for Qt 5.5.1 (QtCreator 5.3.1)?
I have tried various things found online, from enabling/disabling GDB pretty printer, display QString format etc. Nothing seems to work.
(Compiler - MSVC 2013 - 32 bit)
Edit- image:
Many thanks,
Michael

I have encountered the same problem. And I find the solution.
My Qt is 5.9.2. IDE is Qt Creator 4.3.1.
Click Tools->options->Debugger->Local & Expresions->Use Debugging Helper.

I believe you can use the QString::data() function or data_ptr pointer in your QString class.

This was a bug in QT Creator 3.5.1. when webengine was linked to the project (for some reason)
Fix is in Qt Creator 3.6.1. Details are here: https://bugreports.qt.io/browse/QTCREATORBUG-15580

Related

Qt 5.3.1 TableView not updating

Recently I upgraded from Qt 5.3.0 to Qt 5.3.1 and noticed that my TableView's which use a QSortFilterProxyModel as their model no longer update when I sort the proxy model.
You can see this in action by using the sample code here!
If you compile it with Qt 5.3.0 the table will sort but if you compile it with Qt 5.3.1 the model will sort (verified with qDebug statements) but the TableView will not update. This happens on both Windows and Linux.
To get around it I had to add emit layoutChanged() after I call this->sort().
My question is has anyone else noticed this and found out if this is by design or is a defect.
Thanks
I did a little more digging and I found a Qt bug filed for exactly this issue. QTBUG-40035 TableView, Sort doesn't work.
Turns out in Qt 5.3.1 another bug was resolved QTBUG-37983 which changed the QQMLDelegateModel to emit layoutChanged( QList, QAbstractItemModel::LayoutChangedHint) instead of simply emitting layoutChanged(). The TableView does not seem to be listening to the parameratized version of the layoutChanged() signal which is why I can fix this by manually emitting layoutChanged() after I call sort().
This apparently has been fixed by QTBUG-39492 in Qt 5.3.2

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.

Qt Creator no compiler

it's my first time to try QT Creator on my Windows 8. But the problem is, it doesn't detect an existing compiler. My question is how can I add a compiler to get me started? Any ideas? Thanks.
If you're asking about how to add a compiler/kit (aka tool-kit, aka tool-chain) you can find it on a website called stackoverflow. =)
All kidding aside, you may need to download a compiler such as MinGW or Visual Studio Express.

Qt Creator crashes loading Examples

There is an Example tab at the Qt Creator(2.6.1)'s Welcome page, which is supposed to show the already made Qt Project Examples. But whenever I click on that, Qt creator closes automatically. Sometimes it shows the Example projects for 1 or 2 seconds and the exits. Any idea?
You probably need to configure Qt Creator to find your Qt installation.
Compiler configuration for Qt Creator
And you might need to get the msvs compiler, too.
http://www.microsoft.com/visualstudio/eng/products/visual-studio-express-products
They now have the mingw version available for windows with Qt 5.0.2.
http://qt-project.org/downloads
Also if you installed Qt without the examples that may also cause this error.
Hope that helps.

Compiler configuration for Qt Creator

I am new to Qt and its IDE Qt Creator so pardon my ignorance.
When I try to compile my code I get the exception
"Qt Creator needs a compiler set up to build. Configure a compiler in the kit options".
I have installed MingGW for compiling C++ code.
However, I am having a problem configuring it for Qt Creator.
Any help will be appreciated. Thanks
I suspect you are using the new 5.0 Qt. It required a bit of prodding for me too.
If you look into Settings > Build & Run > Kits you should see an auto-detected entry which will probably have an exclamation mark in front and is not editable. Ignore this.
Add a new Kit
Give it a name, set the "Qt version" and select a compiler. (Compilers should have been auto-detected. If you do not see any compilers, you will have to set at least one up manually)
Click the "Make Default" button. (You may have to modify project build settings to use the new Kit too)
There may be a better way, but I do not know it. And you should probably use 4.x until 5 is out of beta.
I was also having the same problem, so what I did was this:
sudo apt-get install g++
sudo apt-get install libgl1-mesa-dev libglu1-mesa-dev
I then closed the QT Creator, restarted it, and it worked.
I do not know which of the above two made it work, but it worked!
You are using Qt Creator 2.6.x, as those are the only ones that have kits.
Please go to Tools>Options>Build & Run>Compilers and add you mingw compiler there. You need to point creator to 'g++' in your mingw installation.
Then head over to the Kits tab and click on the desktop kit that creator should have created for you. In the details there is a field called Compiler (or Tool chain, don't remember). Select your mingw compiler there. Check the debugger field. If it is empty or using the gdb debugger that is part of mingw: Grab a debugger from http://builds.qt-project.org/, install it and point creator to that one. The debuggers delivered as part of mingw are known to not work well with creator.
Do not use the Nokia Qt SDK: Everything in there is terribly outdated by now!
This is just a starting point to troubleshoot your question, but the Qt Creator preferences has settings in the "Build & Run" area where you can define the location of your build toolchain: compiler, Qt version to build, etc. For mingw you'd have to point the right field to the location of g++, for a Qt version the location of qmake.
Not always the last version is the better. If someone is learning Qt to implement production solutions, is not good idea to use Qt version 5 (see the Qt5 change log). If you want to learn Qt programming, I think that the Nokia SDK is a good starting point, because you only have to install it as another Windows software, and start to coding.
By using linux is another good starting point, because you will have all the develop environment with a few apt-get commands.
When I started programming Qt, I lost a lot of hours to get a complete environment working with QtCreator, and I understand that not everybody has time for it.
I am using Qt Creator 3.5.1 based on Qt 5.5.1. The error "No compiler set in kit" has been a problem every time I have to configure a development system. The solution that worked for me is to select Tools/Options/Compilers and add a compiler. In my case a GCC compiler with Name:g++, Compiler path:/usr/bin/g++. The trick is to add the compiler before trying to add a Kit. If I add a Kit before I add a compiler I can never add the compiler to the Kit. If you having this problem delete the Kit, add a compiler, then add the Kit.
In your questions you must provide us more information about your problem, such as what versions of software are you using.
About your question, I think, that very good idea to you (as a beginner) is to use all-in-box QtSDK (link, need registration). There are ready-to-use QtCreator, MinGW and litle bit old Qt Libs in that QtSDK 1.2.1. So, you dont't need to configure it at all.
Hope, it'll help. Good luck!

Resources