Qt 5.5 - QList variable causes compilation to fail
-
HI
Well, its not an include path thing then.
Since the mini sample works.Would it be possible to post your code ?
I really can not get a clue of what could be wrong as you have the includes
and it all sounds ok. -
OK now this is weird. I'm not sure how I came to this, but instead of writing:
QList<QString> m_mylist;
I write:
::QList<QString> m_mylist
It compiles and works... however Qt Creator doesn't seem to like it as the terms QList and QString are not coloured purple as normal.
Any ideas why this works? -
OK now this is weird. I'm not sure how I came to this, but instead of writing:
QList<QString> m_mylist;
I write:
::QList<QString> m_mylist
It compiles and works... however Qt Creator doesn't seem to like it as the terms QList and QString are not coloured purple as normal.
Any ideas why this works?@knight556 said:
OK now this is weird. I'm not sure how I came to this, but instead of writing:
QList<QString> m_mylist;
I write:
::QList<QString> m_mylist
It compiles and works... however Qt Creator doesn't seem to like it as the terms QList and QString are not coloured purple as normal.
Any ideas why this works?- Did you redefine "QList" somewhere else in your code?
- Does this only happen in this particular class, or does it also happen if you add a QList member to other classses?
-
Well that got me thinking, so I had a look and for some reason in another one of my classes I had listed a forward reference to QList. I have now deleted that line of code and the rest of the program compiles and works as expected, without needing the extra :: bits at the start of the QList declaration!
So... clearly I don't understand forward references. Thanks for the help everyone! -
It's pretty unusual to forward declare QList, why did you do that in the first place ?
-
Even QString ?
-
Yep even QString. Is forward referencing even necessary if you put all your includes in the header file? I always thought forward referencing was only needed if you had 2 classes that referenced one another, but of course 1 had to be defined before the other.
-
Yep even QString. Is forward referencing even necessary if you put all your includes in the header file? I always thought forward referencing was only needed if you had 2 classes that referenced one another, but of course 1 had to be defined before the other.
@knight556 said:
Is forward referencing even necessary if you put all your includes in the header file?
No. The header contains more information than the forward declaration, so it doesn't make sense to forward-declare when you already have the header.
I always thought forward referencing was only needed if you had 2 classes that referenced one another, but of course 1 had to be defined before the other.
That's only one use of forward declarations.
It is good practice to minimize the amount of code that you #include inside your headers. When your project gets large, forward declarations really help to speed up compilation times. See http://stackoverflow.com/questions/4757565/c-forward-declaration