Results 1 to 12 of 12

Thread: With a namespace NM created by me, NM:: offers me a lot of data ????

  1. #1
    Join Date
    Sep 2010
    Posts
    654
    Thanks
    56
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default With a namespace NM created by me, NM:: offers me a lot of data ????

    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

  2. #2
    Join Date
    Jan 2006
    Location
    Belgium
    Posts
    1,938
    Thanked 268 Times in 268 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Wiki edits
    20

    Default Re: With a namespace NM created by me, NM:: offers me a lot of data ????

    If shows everything available in the namespace.

  3. #3
    Join Date
    Sep 2010
    Posts
    654
    Thanks
    56
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Again I ask for namespaced and the methods from then than QT offers me

    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

  4. #4
    Join Date
    Sep 2009
    Location
    UK
    Posts
    2,447
    Thanks
    6
    Thanked 348 Times in 333 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Again I ask for namespaced and the methods from then than QT offers me

    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.

  5. #5
    Join Date
    May 2010
    Location
    Romania
    Posts
    1,021
    Thanks
    62
    Thanked 260 Times in 246 Posts
    Qt products
    Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: Again I ask for namespaced and the methods from then than QT offers me

    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?

  6. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Again I ask for namespaced and the methods from then than QT offers me

    Threads merged.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  7. #7
    Join Date
    May 2009
    Location
    Canada
    Posts
    163
    Thanks
    7
    Thanked 20 Times in 20 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Windows Android

    Default Re: Again I ask for namespaced and the methods from then than QT offers me

    Quote Originally Posted by wysota View Post
    Threads merged.
    I note that the icon legend does not include the icon for a merged thread. Are threads merged frequently enough to warrant inclusion? Should the icon be included in the legend regardless?

  8. #8
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Again I ask for namespaced and the methods from then than QT offers me

    The following single file input with Qt Creator 2.0.1 on Linux:
    Qt Code:
    1. #include <QtCore>
    2.  
    3. namespace XYZZY {
    4. int a;
    5. class B { };
    6. class C { };
    7. };
    8.  
    9. class A { };
    10. class B { };
    11. typedef A* APtr;
    12.  
    13. int main(int argc, char *argv[])
    14. {
    15. QCoreApplication app(argc, argv);
    16.  
    17. XYZZY::
    18. }
    To copy to clipboard, switch view to plain text mode 
    Produces this list when asked for completion options after the "XYZZY::" on line 17:
    Qt Code:
    1. A (the global class A)
    2. a (XYZZY::a)
    3. APtr (the global typedef)
    4. B (XYZZY::B)
    5. C (class XYZZY::C)
    6. main (global function)
    7. XYZZY (the namespace itself)
    To copy to clipboard, switch view to plain text mode 
    The OP is asking why this list does not show only:
    Qt Code:
    1. a
    2. B
    3. C
    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.

  9. #9
    Join Date
    Sep 2010
    Posts
    654
    Thanks
    56
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Again I ask for namespaced and the methods from then than QT offers me

    To me, it offers :

    abs
    advance
    allocator
    back_inserter
    ... and so on

    But it is strange, it happens with this :
    Qt Code:
    1. #ifndef WFILE2_H
    2. #define WFILE2_H
    3. #include <string>
    4.  
    5. using namespace std;
    6.  
    7. namespace Wfilee {
    8. class WFileUtiles;
    9. };
    10.  
    11. class WFileUtiles {
    12. public:
    13. WFileUtiles (){}
    14. ~WFileUtiles(){}
    15. long sizefichero(string);
    16. };
    17.  
    18. long WFileUtiles::sizefichero (string path) {
    19. long size;
    20. return size;
    21. }
    22.  
    23.  
    24. #endif // WFILE2_H
    To copy to clipboard, switch view to plain text mode 


    But not with this :
    Qt Code:
    1. #ifndef WGEO_H
    2. #define WGEO_H
    3. #include <string>
    4. using namespace std;
    5.  
    6. namespace Wgeo
    7.  
    8. {
    9. class Wgeo;
    10. class Wconver;
    11. };
    12.  
    13. class Wgeo {
    14.  
    15. public:
    16.  
    17.  
    18. float azimut(double,double,double,double);
    19. };
    20.  
    21. float Wgeo::azimut(double, double, double, double){
    22. return 0.2;
    23. }
    24.  
    25. class Wconver {
    26.  
    27. public:
    28. float utm_geo(int,double,double,double);
    29. };
    30.  
    31. float Wconver::utm_geo(int, double, double, double){
    32. return 0.2;
    33. }
    34.  
    35. #endif // WGEO_H
    To 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.

  10. #10
    Join Date
    Sep 2010
    Posts
    654
    Thanks
    56
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Again I ask for namespaced and the methods from then than QT offers me

    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
    ....
    }

  11. #11
    Join Date
    May 2010
    Location
    Romania
    Posts
    1,021
    Thanks
    62
    Thanked 260 Times in 246 Posts
    Qt products
    Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: Again I ask for namespaced and the methods from then than QT offers me

    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:
    1. //header file
    2. //bla.h
    3. #ifndef BLA
    4. #define BLA
    5. #include <bla_bla>
    6.  
    7. namespace my_namespace {
    8. class T {
    9. public:
    10. T(int);
    11. private:
    12. int mem;
    13. };
    14. }
    15. #endif
    To copy to clipboard, switch view to plain text mode 
    Qt Code:
    1. //bla.cpp
    2.  
    3. #include "bla.h"
    4. namespace my_namespace {
    5. T::T(int t) {
    6. mem = t;
    7. }
    8. }
    To copy to clipboard, switch view to plain text mode 

  12. #12
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Again I ask for namespaced and the methods from then than QT offers me

    Quote Originally Posted by tonnot View Post
    To me, it offers :
    abs
    advance
    allocator
    back_inserter
    ... and so on
    When you use "using namespace std" all the names in the std namespace are exposed in the current one which is why your list is expanded to include these items. In my example, which does not expose std, none of these symbols are visible.
    Last edited by ChrisW67; 30th September 2010 at 00:54. Reason: Always preview first!

Similar Threads

  1. QTSoapMessage namespace
    By ken123 in forum Qt Programming
    Replies: 0
    Last Post: 26th July 2010, 21:36
  2. using namespace with VS integration
    By jan in forum Qt Tools
    Replies: 0
    Last Post: 29th September 2009, 04:20
  3. namespace problem
    By mhoover in forum Qt Programming
    Replies: 4
    Last Post: 11th July 2006, 22:53
  4. QDomDocument and Namespace support?
    By patrik08 in forum Qt Programming
    Replies: 1
    Last Post: 18th May 2006, 10:50

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.