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. Basic problem of main.cpp
Forum Updated to NodeBB v4.3 + New Features

Basic problem of main.cpp

Scheduled Pinned Locked Moved Unsolved General and Desktop
11 Posts 4 Posters 1.1k Views 3 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.
  • Nafab213N Offline
    Nafab213N Offline
    Nafab213
    wrote on last edited by
    #1

    Hello everyone.
    I just started a program and I have a petit when compiling the code.
    When I compile the IDE I get the following errors:
    1 - "FenPrincipale" was not declared in scope
    2 - Expected ";" before window
    3 - "window" was not declared in scope.
    All the errors are located in the main.cpp

    The main.cpp

    #include <QApplication>
    #include <QtWidgets>
    #include "ui_fenprincipale.h"
    
    
    int main(int argc, char *argv[])
    {
        QApplication app(argc, argv);
    
        FenPrincipale fenetre;
        fenetre.show();
    
        return app.exec();
    }
    

    The fenprincipale.h

    #ifndef FENPRINCIPALE_H
    #define FENPRINCIPALE_H
    
    #include <QMainWindow>
    
    namespace Ui {
    class FenPrincipale;
    }
    
    class FenPrincipale : public QMainWindow
    {
        Q_OBJECT
    
    public:
        explicit FenPrincipale(QWidget *parent = 0);
        ~FenPrincipale();
    
    private:
        Ui::FenPrincipale *ui;
    };
    
    #endif // FENPRINCIPALE_H
    
    

    The fenprincipale.cpp

    #include "fenprincipale.h"
    #include "ui_fenprincipale.h"
    
    FenPrincipale::FenPrincipale(QWidget *parent) :
        QMainWindow(parent),
        ui(new Ui::FenPrincipale)
    {
        ui->setupUi(this);
    }
    
    FenPrincipale::~FenPrincipale()
    {
        delete ui;
    }
    

    The errors are in the main.cpp
    Accuracy: I am a beginner so try to explain the solution for me to learn.
    Thanks

    K 2 Replies Last reply
    0
    • Nafab213N Nafab213

      Hello everyone.
      I just started a program and I have a petit when compiling the code.
      When I compile the IDE I get the following errors:
      1 - "FenPrincipale" was not declared in scope
      2 - Expected ";" before window
      3 - "window" was not declared in scope.
      All the errors are located in the main.cpp

      The main.cpp

      #include <QApplication>
      #include <QtWidgets>
      #include "ui_fenprincipale.h"
      
      
      int main(int argc, char *argv[])
      {
          QApplication app(argc, argv);
      
          FenPrincipale fenetre;
          fenetre.show();
      
          return app.exec();
      }
      

      The fenprincipale.h

      #ifndef FENPRINCIPALE_H
      #define FENPRINCIPALE_H
      
      #include <QMainWindow>
      
      namespace Ui {
      class FenPrincipale;
      }
      
      class FenPrincipale : public QMainWindow
      {
          Q_OBJECT
      
      public:
          explicit FenPrincipale(QWidget *parent = 0);
          ~FenPrincipale();
      
      private:
          Ui::FenPrincipale *ui;
      };
      
      #endif // FENPRINCIPALE_H
      
      

      The fenprincipale.cpp

      #include "fenprincipale.h"
      #include "ui_fenprincipale.h"
      
      FenPrincipale::FenPrincipale(QWidget *parent) :
          QMainWindow(parent),
          ui(new Ui::FenPrincipale)
      {
          ui->setupUi(this);
      }
      
      FenPrincipale::~FenPrincipale()
      {
          delete ui;
      }
      

      The errors are in the main.cpp
      Accuracy: I am a beginner so try to explain the solution for me to learn.
      Thanks

      K Offline
      K Offline
      kenchan
      wrote on last edited by
      #2
      This post is deleted!
      1 Reply Last reply
      0
      • Nafab213N Nafab213

        Hello everyone.
        I just started a program and I have a petit when compiling the code.
        When I compile the IDE I get the following errors:
        1 - "FenPrincipale" was not declared in scope
        2 - Expected ";" before window
        3 - "window" was not declared in scope.
        All the errors are located in the main.cpp

        The main.cpp

        #include <QApplication>
        #include <QtWidgets>
        #include "ui_fenprincipale.h"
        
        
        int main(int argc, char *argv[])
        {
            QApplication app(argc, argv);
        
            FenPrincipale fenetre;
            fenetre.show();
        
            return app.exec();
        }
        

        The fenprincipale.h

        #ifndef FENPRINCIPALE_H
        #define FENPRINCIPALE_H
        
        #include <QMainWindow>
        
        namespace Ui {
        class FenPrincipale;
        }
        
        class FenPrincipale : public QMainWindow
        {
            Q_OBJECT
        
        public:
            explicit FenPrincipale(QWidget *parent = 0);
            ~FenPrincipale();
        
        private:
            Ui::FenPrincipale *ui;
        };
        
        #endif // FENPRINCIPALE_H
        
        

        The fenprincipale.cpp

        #include "fenprincipale.h"
        #include "ui_fenprincipale.h"
        
        FenPrincipale::FenPrincipale(QWidget *parent) :
            QMainWindow(parent),
            ui(new Ui::FenPrincipale)
        {
            ui->setupUi(this);
        }
        
        FenPrincipale::~FenPrincipale()
        {
            delete ui;
        }
        

        The errors are in the main.cpp
        Accuracy: I am a beginner so try to explain the solution for me to learn.
        Thanks

        K Offline
        K Offline
        kenchan
        wrote on last edited by
        #3

        @Nafab213 said in Basic problem of main.cpp:

        #include "ui_fenprincipale.h"

        You should have

        #include "fenprincipale.h"
        

        in your main.cpp file

        Nafab213N 1 Reply Last reply
        4
        • K kenchan

          @Nafab213 said in Basic problem of main.cpp:

          #include "ui_fenprincipale.h"

          You should have

          #include "fenprincipale.h"
          

          in your main.cpp file

          Nafab213N Offline
          Nafab213N Offline
          Nafab213
          wrote on last edited by
          #4

          @kenchan
          Everything is working now but I have another problem.
          In the Qt Designer, I put a File left and vertical file and an Edit toolbar on the top left but it does not take compilation. When I leave the file and return to the file the file toolbar returns to the top left side.
          How to write define the modification of the position and the size of my toolbar.
          I'm sending you an image to show you.

          0_1550400672391_Capture.PNG

          The File Toolbar is on the left
          The toolbar Edition is in the middle but I want them defensively in the following order:
          ToolbarLong Vertical File
          ToolbarEdition Up Horizontal
          Can I help?

          K 1 Reply Last reply
          0
          • Nafab213N Nafab213

            @kenchan
            Everything is working now but I have another problem.
            In the Qt Designer, I put a File left and vertical file and an Edit toolbar on the top left but it does not take compilation. When I leave the file and return to the file the file toolbar returns to the top left side.
            How to write define the modification of the position and the size of my toolbar.
            I'm sending you an image to show you.

            0_1550400672391_Capture.PNG

            The File Toolbar is on the left
            The toolbar Edition is in the middle but I want them defensively in the following order:
            ToolbarLong Vertical File
            ToolbarEdition Up Horizontal
            Can I help?

            K Offline
            K Offline
            kenchan
            wrote on last edited by
            #5

            @Nafab213

            Not sure just by looking at that picture. They look to be the correct orientation to me. Is the horizontal one actually docked at the top, or is it floating?
            You can restrict where they can dock, that might help.

            Nafab213N 1 Reply Last reply
            0
            • K kenchan

              @Nafab213

              Not sure just by looking at that picture. They look to be the correct orientation to me. Is the horizontal one actually docked at the top, or is it floating?
              You can restrict where they can dock, that might help.

              Nafab213N Offline
              Nafab213N Offline
              Nafab213
              wrote on last edited by
              #6

              @kenchan said in Basic problem of main.cpp:

              Not sure just by looking at that picture. They look to be the correct orientation to me. Is the horizontal one actually docked at the top, or is it floating?
              You can restrict where they can dock, that might help.

              How can I restrict their access?
              Explain to me ....

              K 1 Reply Last reply
              0
              • Nafab213N Nafab213

                @kenchan said in Basic problem of main.cpp:

                Not sure just by looking at that picture. They look to be the correct orientation to me. Is the horizontal one actually docked at the top, or is it floating?
                You can restrict where they can dock, that might help.

                How can I restrict their access?
                Explain to me ....

                K Offline
                K Offline
                kenchan
                wrote on last edited by kenchan
                #7

                @Nafab213

                Click on the toolbar in the object list on the right hand side of the Design screen.
                look at the properties for the QToolBar object at the bottom of the property list.
                Check the allowedAreas that you want to restrict the toolbars docking to.

                Nafab213N 1 Reply Last reply
                1
                • mrjjM Offline
                  mrjjM Offline
                  mrjj
                  Lifetime Qt Champion
                  wrote on last edited by
                  #8

                  Hi
                  The docking places looks like this
                  alt text

                  so i think you can only place them like
                  alt text

                  and not like
                  alt text

                  Nafab213N 1 Reply Last reply
                  0
                  • mrjjM mrjj

                    Hi
                    The docking places looks like this
                    alt text

                    so i think you can only place them like
                    alt text

                    and not like
                    alt text

                    Nafab213N Offline
                    Nafab213N Offline
                    Nafab213
                    wrote on last edited by
                    #9

                    @mrjj
                    Thanks for the advice but I decided to put all the toolbar up and horizontal.
                    Now I have another question ..

                    On my main page there are two buttons.
                    If we click on the button 1
                    I would like a table to appear instead of the centralwidget of my window (I intend to create the new Qwidget class called TableauCene). The button 1 will be connected to the slot (showcene) which will display as centralwidget Tableaucene.

                    If we click on the Boutton 2
                    I would like a table to appear instead of the centralwidget of my window (I intend to create the new Qwidget class called TableauCenep). Button 2 will be connected to the slot (showcenep) which will display as the tableapple centralwidget.

                    How can I program slots "showcene" and "showcenep"?
                    Thanks for your help....

                    1 Reply Last reply
                    0
                    • K kenchan

                      @Nafab213

                      Click on the toolbar in the object list on the right hand side of the Design screen.
                      look at the properties for the QToolBar object at the bottom of the property list.
                      Check the allowedAreas that you want to restrict the toolbars docking to.

                      Nafab213N Offline
                      Nafab213N Offline
                      Nafab213
                      wrote on last edited by
                      #10

                      @kenchan
                      Thanks for the advice but I decided to put all the toolbar up and horizontal.
                      Now I have another question ..
                      On my main page there are two buttons.
                      If we click on the button 1
                      I would like a table to appear instead of the centralwidget of my window (I intend to create the new Qwidget class called TableauCene). The button 1 will be connected to the slot (showcene) which will display as centralwidget Tableaucene.

                      If we click on the Boutton 2
                      I would like a table to appear instead of the centralwidget of my window (I intend to create the new Qwidget class called TableauCenep). Button 2 will be connected to the slot (showcenep) which will display as the tableapple centralwidget.

                      How can I program slots "showcene" and "showcenep"?
                      Thanks for your help....

                      1 Reply Last reply
                      0
                      • M Offline
                        M Offline
                        mpergand
                        wrote on last edited by mpergand
                        #11

                        Salut,

                        Have a look at QStackedWidget or QTabWidget, they are commonly use for the things you've described.

                        1 Reply Last reply
                        3

                        • Login

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