PDA

View Full Version : Qt Creator IDE doesn't suggest the methods



expert_vision
2nd January 2013, 12:06
I'm a total newbie to OOP but I know this, whenever I type "." next to an object, IDE nicely shows me all of it's methods and functions. But not in this case:

void Widget::on_Start_clicked()
{
...
QTextStream stream(&file);
QString content = stream.readAll();
QStringList lines = content.split("\\n");
lines.at(0).
but if I do this:

void Widget::on_Start_clicked()
{
...
QTextStream stream(&file);
QString content = stream.readAll();
QStringList lines = content.split("\\n");
QString line = lines.at(0);
line.
it works.

So .. what's going on?

ChrisW67
3rd January 2013, 05:37
The editor probably cannot see a full definition of QStringList, just a forward declaration, so it has no idea that QStringList::at() exists and returns QString. If you #include <QStringList> you should see a change.

expert_vision
3rd January 2013, 17:31
No, it does suggest the methods for the QStringList object, but it does not suggest the methods for the QString object inside the QStringList object.
Basically what I need to write is lines.at(0).toInt(); , and toInt() is not suggested.
I did include QString and QStringList, but that didn't do the trick.

boudie
3rd January 2013, 22:39
Both examples work without any problem here (using Qt Creator 2.4.1 on Ubuntu Linux).

ChrisW67
3rd January 2013, 23:45
Which Qt Creator version?
Does the code actually compile? Qt Creator can be a bit fussy if there are earlier broken bits of code in the file: they break the parser. Older versions of Creator are fussier.

expert_vision
5th January 2013, 10:50
I use Qt Creator 2.0.1 with Qt 4.7.0 on Ubuntu 64-bit.
Yes, the code still compiles if I type it down myself.
I should probably upgrade, but I'm a bit afraid I might broke Qt, and that would be very unfortunate. :P
Anyway, maybe I'll try install the suggested Qt Creator on a new VM.

ChrisW67
5th January 2013, 20:17
You don't need to upgrade the Qt libraries, just Qt Creator.

hunger
6th January 2013, 00:51
You don't need to upgrade the Qt libraries, just Qt Creator.

Unfortunately Creator is not very good with templates, so upgrading Creator will not help here:(

There is work ongoing to finally fix this by using a clang-based c++ parser. While that fixes this issue it is unfortunately too slow for now (it can not take the shortcuts the current parser takes which e.g. break most templates). So we need to come up with some way to cache the code model data in some way or another or speed up clang for the use-case of Qt Creator.

ChrisW67
6th January 2013, 05:27
Creator is not very good with templates, so upgrading Creator will not help here
Really? Qt Creator 2.6.1 with the example the OP gave works just fine here (as was pointed out earlier by boudie for Creator 2.4.1). What is certain is that if you don't upgrade Qt Creator you will not see the benefit of improvements.
8558