Warning when initializing data members



  • Hi,
    When I initialize data members such as

    QLineEdit *LineEdit_Name = new QLineEdit;
    

    I get the following warning:
    warning: non-static data member initializers only available with -std=c++11 or -std=gnu++11
    QLineEdit *LineEdit_Name = new QLineEdit;

    Any idea why?
    Thank you.
    ^


  • Moderators

    Are you trying to do it directly in the class like:

    class MyClass
    {
        private:
            QLineEdit *LineEdit_Name = new QLineEdit;
    }
    

    Do the initialisation in the constructor of your class.
    Or activate C++11 support like the error message suggests (add CONFIG += c++11 to the PRO file).



  • Thank you.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.