Results 1 to 20 of 23

Thread: Problems accessing static member variable from static member function

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Aug 2008
    Location
    Ukraine, Krivoy Rog
    Posts
    1,963
    Thanked 370 Times in 336 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Problems accessing static member variable from static member function

    you must init static variable
    Qt Code:
    1. QComboBox *Test::m_comboBox = new QComboBox();
    To copy to clipboard, switch view to plain text mode 

    why do you need this method of storing/getting of QComboBox?
    Last edited by spirit; 7th October 2008 at 12:51. Reason: spelling error

  2. The following user says thank you to spirit for this useful post:

    montylee (7th October 2008)

  3. #2
    Join Date
    Oct 2007
    Location
    India
    Posts
    162
    Thanks
    20
    Thanked 6 Times in 5 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Problems accessing static member variable from static member function

    Quote Originally Posted by spirit View Post
    you must init static variable
    Qt Code:
    1. QComboBox *Test::m_comboBox = new QComboBox();
    To copy to clipboard, switch view to plain text mode 

    why do you need this method of storing/getting of QComboBox?
    i already got my solution... i have posted it...

    I need to get the combo box pointer as i need to add items to it from a different class.

    If i use a normal member function to return the combo box pointer it won't work as as i have to first create an instance of this class in the other class to invoke the member function. As soon as i create an instance, the member combo box variable is allocated a new memory and i am not able to get the original combo box pointer.

    So , i have to call it directly without using an object, so i have to use either statiic or a global variable...

    pls read my earlier post and suggest if i should go for global or static member variable.

Similar Threads

  1. QPSQL problem
    By LoneWolf in forum Installation and Deployment
    Replies: 60
    Last Post: 4th November 2009, 14:22
  2. QPSQL driver in windows
    By brevleq in forum Installation and Deployment
    Replies: 31
    Last Post: 14th December 2007, 12:57
  3. how to add static library into qmake
    By Namrata in forum Qt Tools
    Replies: 1
    Last Post: 20th November 2007, 17:33
  4. use qpsql
    By raphaelf in forum Installation and Deployment
    Replies: 34
    Last Post: 22nd August 2006, 12:52
  5. I got two problems when I used static compiled library of QT4
    By qintm in forum Installation and Deployment
    Replies: 8
    Last Post: 20th April 2006, 08:52

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.