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. Namespace enclosing 'MainWindow' [-fpermissive]
Forum Updated to NodeBB v4.3 + New Features

Namespace enclosing 'MainWindow' [-fpermissive]

Scheduled Pinned Locked Moved General and Desktop
7 Posts 2 Posters 2.5k Views 1 Watching
  • 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.
  • R Offline
    R Offline
    riadara
    wrote on last edited by
    #1

    mainwindow.h
    @
    #ifndef MAINWINDOW_H
    #define MAINWINDOW_H

    #include <QMainWindow>
    #include <QtCore>
    #include <QtGui>
    #include <QtWidgets>
    #include <QGraphicsOpacityEffect>
    #include <QtSql>
    #include <QPrinter>
    #include "dark.h"

    namespace Ui {
    class MainWindow;
    }

    class MainWindow : public QMainWindow
    {
    Q_OBJECT

    protected:

    void closeEvent(QCloseEvent *event);
    

    public:

      explicit MainWindow(QWidget *parent = 0);
    ~MainWindow();
    

    public slots:

    private:

    Ui::MainWindow *ui;
    

    private slots:

    void animeTDB();
    

    };

    #endif // MAINWINDOW_H
    @

    mainwindow.cpp
    @
    MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
    {
    ui->setupUi(this);

    }
    @

    error

    definition of 'MainWindow::MainWindow(QWidget*)' is not in namespace enclosing 'MainWindow' [-fpermissive]
    MainWindow::MainWindow(QWidget *parent) :
    ^

    [edit: added missing coding tags @ SGaist]

    1 Reply Last reply
    0
    • C Offline
      C Offline
      ckakman
      wrote on last edited by
      #2

      Hi,

      Could you paste the complete mainwindow.cpp. Apparently it is not complete because I don't see the following #include in the listing:
      @#include "mainwindow.h"@

      1 Reply Last reply
      0
      • R Offline
        R Offline
        riadara
        wrote on last edited by
        #3

        Oh yes, sorry im forgot it, if you want the full project just tell me to send you in your mail because it very long, the same error for all functions in mainwindow.cpp. thanks. sorry for my english

        mainwindow.cpp

        #include "mainwindow.h"
        #include "ui_mainwindow.h"

        MainWindow::MainWindow(QWidget *parent) :
        QMainWindow(parent),
        ui(new Ui::MainWindow)
        {
        ui->setupUi(this);
        ...
        ...
        .
        }

        1 Reply Last reply
        0
        • C Offline
          C Offline
          ckakman
          wrote on last edited by
          #4

          Could you remove #include "dark.h" from mainwindow.h, comment out all the code using anything from dark.h and recompile your project.

          I think there is a namespace somewhere accesible via dark.h which is not closed properly so that the compiler thinks that that MainWindow class definition in mainwindow.h is in that namespace. But since the definition of MainWindow's methods in mainwindows.cpp are not in that namespace you get this error.

          By the way I don't know anything about the -fpermissive flag.

          1 Reply Last reply
          0
          • R Offline
            R Offline
            riadara
            wrote on last edited by
            #5

            Not match, the same error

            download and compile my project at this link "click here":https://1fichier.com/?blujqp859m please help me.

            1 Reply Last reply
            0
            • C Offline
              C Offline
              ckakman
              wrote on last edited by
              #6

              Just what I expected: the PME namespace in pme.h is missing the closing brace. Add a '}' at the bottom of the pme.h before the #endif and you will start getting your more regular compile errors.

              Disabling dark.h in mainwindows.h couldn't have worked since there are more than 15 non-Qt headers in mainwindows.cpp. pme.h was not seen via dark.h but directly #include'd in the cpp file.

              1 Reply Last reply
              0
              • R Offline
                R Offline
                riadara
                wrote on last edited by
                #7

                it match thank you very mush

                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