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 Update on Monday, May 27th 2025

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 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
    • jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on 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 last edited by
        #3

        Thank you.

        1 Reply Last reply
        0

        • Login

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