I have a own namespace in my h file, for example AAA
Later, If I write AAA:: QTCreator offers me a combo with a lot of methods, classes, etc.
I only want to see my elements, not the others
Whats happen ?
Thanks
I have a own namespace in my h file, for example AAA
Later, If I write AAA:: QTCreator offers me a combo with a lot of methods, classes, etc.
I only want to see my elements, not the others
Whats happen ?
Thanks
If shows everything available in the namespace.
I have my own namespace, for example nms
When I write nms:: QT offers me a list with a lot of methods, but I only have one in 'myfile.h'.
Whats happen ? I only want to see my methods .
Any idea ?
Thanks
If you don't like the answer someone has given to your post, the best solution is not to repost the same question with "again:" prefixed to it.
We did notice your thread yesterday. We didn't miss it. We just decided to not reply as a suitable reply was already posted.
Anyway, i can't replicate your problem, so please post a minimal example that replicate the issue, because i think you are doing some unnecessary things in there.
Like, include/using some Qt header in the namespace?
The following single file input with Qt Creator 2.0.1 on Linux:
Produces this list when asked for completion options after the "XYZZY::" on line 17:Qt Code:
#include <QtCore> namespace XYZZY { int a; class B { }; class C { }; }; class A { }; class B { }; typedef A* APtr; int main(int argc, char *argv[]) { XYZZY:: }To copy to clipboard, switch view to plain text mode
The OP is asking why this list does not show only:Qt Code:
A (the global class A) a (XYZZY::a) APtr (the global typedef) B (XYZZY::B) C (class XYZZY::C) main (global function) XYZZY (the namespace itself)To copy to clipboard, switch view to plain text mode
as valid completions here. I think the answer is that Qt Creator is not a full blown C++ compiler and makes some approximations when parsing the sources. AFAICT there is no way to adjust this behaviour.
To me, it offers :
abs
advance
allocator
back_inserter
... and so on
But it is strange, it happens with this :
Qt Code:
#ifndef WFILE2_H #define WFILE2_H #include <string> using namespace std; namespace Wfilee { class WFileUtiles; }; class WFileUtiles { public: WFileUtiles (){} ~WFileUtiles(){} long sizefichero(string); }; long WFileUtiles::sizefichero (string path) { long size; return size; } #endif // WFILE2_HTo copy to clipboard, switch view to plain text mode
But not with this :
Qt Code:
#ifndef WGEO_H #define WGEO_H #include <string> using namespace std; namespace Wgeo { class Wgeo; class Wconver; }; class Wgeo { public: float azimut(double,double,double,double); }; float Wgeo::azimut(double, double, double, double){ return 0.2; } class Wconver { public: float utm_geo(int,double,double,double); }; float Wconver::utm_geo(int, double, double, double){ return 0.2; } #endif // WGEO_HTo copy to clipboard, switch view to plain text mode
It is possible than this code does not compile...
Last edited by tonnot; 29th September 2010 at 09:09.
A new problem.
If i use the 'header' namespace style , must I declare all the functions of my classes ? The compiler give me errors ...
A quick solution is to include all my code into the namespace, like this :
namespace NM {
code
code
code
....
}
First issue: Don't use: using namespace std; (or any other namespace) in header files;
2) Use the same declaration in .h file and definition in .cpp file, just like you are not using namespace:
Qt Code:
//header file //bla.h #ifndef BLA #define BLA #include <bla_bla> namespace my_namespace { class T { public: T(int); private: int mem; }; } #endifTo copy to clipboard, switch view to plain text modeQt Code:
//bla.cpp #include "bla.h" namespace my_namespace { T::T(int t) { mem = t; } }To copy to clipboard, switch view to plain text mode
Last edited by ChrisW67; 30th September 2010 at 00:54. Reason: Always preview first!
Bookmarks