Donotalo Donotalo - 1 month ago 20
C++ Question

Qt Creator cannot resolve STL containers

I've downloaded Qt 5.4 for Windows, running it in Windows 8.1 Pro. It comes with MingW and Qt Creator 3.3.

I've been using Qt for few years. Still a very necessary component seems missing in the Qt Creator IDE. Suppose a class

Card
is defined with a function
getSymbol()
:

class Card
{
public:
string getSymbol() const;
}


Somewhere in code I've a
std::vector
of
Card
s:

vector<Card> playable;


And somewhere else in code:

playable[0].getSymbol();
^----------------- Note this dot


When I type the period in the line above, Qt Creator should list available functions and variables of
Card
class to be used, just like IntelliSense works in VS. But that doesn't happen. However, when I create an object of type
Card
, then the dot triggers Qt Creator to show available functions:

enter image description here

Why this feature doesn't work when
Card
objects are put in STL containers? Is there any settings that needs to be enabled?

Answer

This has been a long standing issue discussed asked and asked over again on forums and mailing lists. As thuga correctly showed in the comment, this is the corresponding bugreport to monitor:

Code completion does not work for std::vector of objects

Note that QtCreator was primarily meant for working with Qt code and so you would use QVector in such projects which is working. I am not saying that it is not worth fixing, but that is at least the history.

This may be getting closer and closer with using clang inside QtCreator, but I guess you will need to wait.