Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Basic problem of main.cpp



  • 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



  • This post is deleted!


  • @Nafab213 said in Basic problem of main.cpp:

    #include "ui_fenprincipale.h"

    You should have

    #include "fenprincipale.h"
    

    in your main.cpp file



  • @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?



  • @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.



  • @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 ....



  • @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.


  • Lifetime Qt Champion

    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



  • @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....



  • @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....



  • Salut,

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


Log in to reply