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. "nullptr" was not declared in scope
QtWS25 Last Chance

"nullptr" was not declared in scope

Scheduled Pinned Locked Moved Unsolved General and Desktop
7 Posts 4 Posters 9.3k 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.
  • N Offline
    N Offline
    Nafab213
    wrote on 18 Feb 2019, 22:36 last edited by
    #1

    Hi
    I am a beginner and currently I am working on a program.
    I have a main class called "FenPrincipale" of daughter classes "FenCene" and "FenCenep".

    My IDE sends me the following error at fencen.h and fencenep.h

    "nullptr was not declared in the scope"
    "identify 'nullptr' is a keyword in C ++ [-wc ++ 0x-compat]

    The notification is the same in the headers of the two classes.

    Here is the code of fencene.h

    #ifndef FENCENE_H
    #define FENCENE_H
    
    #include <QObject>
    #include <QWidget>
    
    namespace Ui {
    class FenCene;
    }
    
    class FenCene : public QWidget
    {
        Q_OBJECT
    
    public:
        explicit FenCene(QWidget *parent = nullptr);
        ~FenCene();
    
    private:
        Ui::FenCene *ui;
    };
    
    #endif // FENCENE_H
    
    

    Here is the code of fencenep.h

    #ifndef FENCENEP_H
    #define FENCENEP_H
    
    #include <QWidget>
    
    
    namespace Ui {
    class FenCenep;
    }
    
    class FenCenep : public QWidget
    {
        Q_OBJECT
    
    public:
        explicit FenCenep(QWidget *parent = nullptr);
        ~FenCenep();
    
    private:
        Ui::FenCenep *ui;
    };
    
    #endif // FENCENEP_H
    
    

    Here is the code of fenprincipale.h

    #ifndef FENPRINCIPALE_H
    #define FENPRINCIPALE_H
    
    #include <QMainWindow>
    #include <QWidget>
    #include <QStackedWidget>
    #include "fencene.h"
    #include "fencenep.h"
    
    
    namespace Ui {
    class FenPrincipale;
    }
    
    class FenPrincipale : public QMainWindow
    {
        Q_OBJECT
    
    public:
        explicit FenPrincipale(QWidget *parent = 0);
        ~FenPrincipale();
    
    private:
        Ui::FenPrincipale *ui;
        QWidget *fencen;
        QStackedWidget *centralfencen;
    
    
    public slots:
        void Affichefencene();
        void Affichefencenep();
    
    };
    
    #endif // FENPRINCIPALE_H
    
    

    What can I do to fix the problem?

    Thank you in advance....

    1 Reply Last reply
    0
    • F Offline
      F Offline
      fcarney
      wrote on 18 Feb 2019, 22:46 last edited by
      #2

      This might help:
      https://stackoverflow.com/questions/16509932/using-qt-creator-c-11-nullptr-is-keyworded

      Are you running an old project or something new?
      What version of Qt are you running? 5.12?

      Most new projects should have CONFIG += c++11 defined already in PRO file.

      C++ is a perfectly valid school of magic.

      1 Reply Last reply
      3
      • N Offline
        N Offline
        Nafab213
        wrote on 18 Feb 2019, 22:57 last edited by
        #3

        I'm running a new project.
        I am using Qt version 5.1.0

        What else can I do?
        Thanks

        1 Reply Last reply
        0
        • F Offline
          F Offline
          fcarney
          wrote on 18 Feb 2019, 23:12 last edited by
          #4

          5.1.0 is really old. I would get 5.12 for new projects. I am not sure if 5.1.0 had support for c++11 by default.

          C++ is a perfectly valid school of magic.

          N 1 Reply Last reply 18 Feb 2019, 23:14
          2
          • F fcarney
            18 Feb 2019, 23:12

            5.1.0 is really old. I would get 5.12 for new projects. I am not sure if 5.1.0 had support for c++11 by default.

            N Offline
            N Offline
            Nafab213
            wrote on 18 Feb 2019, 23:14 last edited by
            #5

            @fcarney
            The problem is that I do not know how to update my Qt from version 5.1.0 to 5.1.2 ...

            J 1 Reply Last reply 19 Feb 2019, 05:25
            0
            • N Nafab213
              18 Feb 2019, 23:14

              @fcarney
              The problem is that I do not know how to update my Qt from version 5.1.0 to 5.1.2 ...

              J Offline
              J Offline
              jsulm
              Lifetime Qt Champion
              wrote on 19 Feb 2019, 05:25 last edited by
              #6

              @Nafab213 Did you add CONFIG += c++11 to your pro file as @fcarney suggested? nullptr requires C++11 compiler and when using GCC you need activate C++11. What is the compiler version?

              "The problem is that I do not know how to update my Qt from version 5.1.0 to 5.1.2" - how did you install Qt?

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

              1 Reply Last reply
              4
              • S Offline
                S Offline
                SGaist
                Lifetime Qt Champion
                wrote on 19 Feb 2019, 22:55 last edited by
                #7

                Hi,

                To add to my fellows: the suggestion is to update to 5.12 not 5.1.2.

                Interested in AI ? www.idiap.ch
                Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                1 Reply Last reply
                1

                3/7

                18 Feb 2019, 22:57

                • Login

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