Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Warning when initializing data members
Forum Updated to NodeBB v4.3 + New Features

Warning when initializing data members

Scheduled Pinned Locked Moved Solved General and Desktop
warninginitialize
3 Posts 2 Posters 1.1k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • G Offline
    G Offline
    gabor53
    wrote on 1 Feb 2016, 04:20 last edited by
    #1

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

    1 Reply Last reply
    0
    • J Offline
      J Offline
      jsulm
      Lifetime Qt Champion
      wrote on 1 Feb 2016, 05:22 last edited by
      #2

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

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • G Offline
        G Offline
        gabor53
        wrote on 1 Feb 2016, 14:46 last edited by
        #3

        Thank you.

        1 Reply Last reply
        0

        2/3

        1 Feb 2016, 05:22

        • Login

        • Login or register to search.
        2 out of 3
        • First post
          2/3
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved