Results 1 to 9 of 9

Thread: global variable in QT: getting ISSUES

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Sep 2010
    Location
    Chennai
    Posts
    37
    Thanks
    8
    Qt products
    Qt4
    Platforms
    MacOS X

    Arrow global variable in QT: getting ISSUES

    hi,
    I am using following code for making global variable. But I am getting the error:
    :: error: duplicate symbol _m_pInstance in citybook.o and main.o
    :: error: collect2: ld returned 1 exit status

    My code : CityBookGlobalVariables.h
    Qt Code:
    1. #ifndef CITYBOOKGLOBALVARIABLES_H
    2. #define CITYBOOKGLOBALVARIABLES_H
    3. #include <QStringList>
    4. class CityBookGlobalVariables
    5. {
    6. private:
    7. CityBookGlobalVariables(){};
    8. CityBookGlobalVariables( const CityBookGlobalVariables& _instance ){};
    9. static CityBookGlobalVariables* m_pInstance;
    10.  
    11.  
    12. public:
    13.  
    14. QStringList m_cityList;
    15. static CityBookGlobalVariables* instance()
    16. {
    17. if ( !m_pInstance )
    18. m_pInstance = new CityBookGlobalVariables;
    19.  
    20. return m_pInstance;
    21. }
    22.  
    23. void setCityList(QStringList cityList)
    24. {
    25. m_cityList = cityList;
    26. }
    27.  
    28. QStringList getCityList()
    29. {
    30. return m_cityList;
    31. }
    32. };
    33.  
    34. CityBookGlobalVariables* m_pInstance = 0;
    35. #endif // CITYBOOKGLOBALVARIABLES_H
    To copy to clipboard, switch view to plain text mode 

    please help me. Thanks in advance
    Last edited by Girija; 19th September 2010 at 14:45.

Similar Threads

  1. Setting a global variable
    By Windsoarer in forum Qt Programming
    Replies: 3
    Last Post: 16th February 2010, 22:37
  2. how to declare a global variable right
    By Cruz in forum Newbie
    Replies: 13
    Last Post: 16th February 2010, 16:25
  3. linking a slider to a global variable
    By switch in forum Newbie
    Replies: 6
    Last Post: 5th August 2009, 08:02
  4. Link QVariant to global variable
    By jobrandt in forum Qt Programming
    Replies: 2
    Last Post: 8th May 2007, 10:18
  5. global variable
    By Shuchi Agrawal in forum General Programming
    Replies: 10
    Last Post: 15th February 2007, 04:19

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
  •  
Qt is a trademark of The Qt Company.