IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Discussion :

Fuite de mémoire

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre averti
    Homme Profil pro
    Formateur en informatique
    Inscrit en
    Février 2015
    Messages
    59
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 46
    Localisation : France, Seine Maritime (Haute Normandie)

    Informations professionnelles :
    Activité : Formateur en informatique
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Février 2015
    Messages : 59
    Par défaut Fuite de mémoire
    Bonsoir tout le monde.

    Je me permet de faire appel à vos lumières car je sèche sur un problème.

    Il y a de ça plusieurs mois, je me suis lancé dans l'apprentissage du C++ et suis donc passé par Qt et la SFML.

    Dans le but de m'améliorer et surtout de manipuler ce que j'ai appris je me suis lancé dans le codage d'un jeu vidéo (via SFML), un Zelda like, que j'ai mis entre parenthèse pour créer une application pour mon travail. J'avais alors demandé un peu d'aide ici http://www.developpez.net/forums/d15...besoin-d-aide/

    Travaillant dans un magasin, mon application a pour but d'aider les clients à trouver les cartouches d'encre correspondant à leurs imprimantes en sélectionnant la marque, puis encre ou laser, puis la famille et enfin le modèle.

    Mon application est maintenant terminée (enfin la v1) et est fonctionnelle. J'ai codé cette application via Qt 5.4.1.

    J'ai cependant un problème de fuite de mémoire...

    Ma "v1" est constituée, au niveau code, d'un "joli bordel".

    Pour me simplifier le travail pour les ajouts (modèles d'imprimantes...) j'ai une base de données sous forme d'un fichier .txt et mon application qui va lire les informations correspondant aux boutons du modèle cliqué.

    Mon application en elle même est composée :
    - d'une page principale de sélection de marques qui est fixe et ne doit pas être fermée
    - d'une fenêtre de sélection de type (encre ou laser) - par marque (qui se ferme lors de l'ouverture de la suivante ou pour revenir à la page principale)
    - d'une fenêtre de sélection de famille - par type et par marque (qui se ferme lors de l'ouverture de la suivante ou pour revenir à la page principale)
    - d'une fenêtre de sélection de modèle - par famille, type et marque (qui se ferme lors de l'ouverture de la suivante ou pour revenir à la page principale)
    - et enfin d'une fenêtre finale qui affiche les références des cartouches - cette page est commune à tous les modèles (qui se ferme lors de l'ouverture de la suivante ou pour revenir à la page principale)

    Donc : 6 marques, 2 type par marque, plusieurs famille par type, quelques milliers de modèles en tout et une page finale... ça donne le main.cpp + 175 ".cpp" + 175 ".h" (d'où le "joli bordel"... sans compter les quelques images pour que ça soit joli et la base de données .txt).

    Quand j'exécute mon application elle utilise environ 440 Mo de mémoire vive à peine ouverte et à chaque fois que je clique sur un bouton (pour ouvrir la page suivante) cela me rajoute 5 Mo à chaque fois seulement au 1er lancement de chaque page (exemple, si j'ouvre 10 fois la page de la marque 1, je n'ai qu'une fois 5 Mo ajouté).

    Voilà mon problème...

    Et vu que c'est une application qui tournera en permanence tout au long de la journée, cela va vite saturer la mémoire vive...

    Auriez-vous une idée pour régler mon problème ?

    Par avance merci

    P.S. : le code arrive dans mon post suivant pour faciliter la lecture

  2. #2
    Membre averti
    Homme Profil pro
    Formateur en informatique
    Inscrit en
    Février 2015
    Messages
    59
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 46
    Localisation : France, Seine Maritime (Haute Normandie)

    Informations professionnelles :
    Activité : Formateur en informatique
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Février 2015
    Messages : 59
    Par défaut Mon code (enfin pas tout car très long)
    Je ne vais pas mettre tout mon code, car très long, mais le code du main et de chaque page pour le chemin depuis le choix d'une marque, d'un type (encre), d'une famille, d'un modèle et enfin la page affichant les références.

    Voici le main.cpp :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    #include <QApplication>
     
    #include "MainWindow.h"
     
     
    int main(int argc, char *argv[])
    {
        QApplication app(argc, argv);
     
        MainWindow window;
        window.show();
     
        return app.exec();
    }
    Ma fenêtre principale (choix de marque) :
    MainWindow.h
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    #ifndef MAINWINDOW
    #define MAINWINDOW
     
    #include <QtWidgets>
    #include "Init.h"
    #include "BrotherTypeWindow.h"
    #include "CanonTypeWindow.h"
    #include "EpsonTypeWindow.h"
    #include "HPTypeWindow.h"
    #include "LexmarkTypeWindow.h"
    #include "SamsungTypeWindow.h"
     
    class MainWindow : public QWidget
    {
        Q_OBJECT
     
        public:
        MainWindow();
     
        private slots:
        void runBrother();
        void runCanon();
        void runEpson();
        void runHp();
        void runLexmark();
        void runSamsung();
     
        private:
        QPushButton *brotherButton;
        QPushButton *canonButton;
        QPushButton *epsonButton;
        QPushButton *hpButton;
        QPushButton *lexmarkButton;
        QPushButton *samsungButton;
     
        QPushButton *logo;
     
        BrotherTypeWindow brotherTypeWindow;
        CanonTypeWindow canonTypeWindow;
        EpsonTypeWindow epsonTypeWindow;
        HPTypeWindow hpTypeWindow;
        LexmarkTypeWindow lexmarkTypeWindow;
        SamsungTypeWindow samsungTypeWindow;
     
        void Button();
        void Slots();
    };
     
    #endif // MAINWINDOW
    MainWindow.cpp
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    #include "MainWindow.h"
     
    MainWindow::MainWindow() : QWidget()
    {
        setMaximumSize(Init::WINDOW_WIDTH, Init::WINDOW_HEIGHT);
        setMinimumSize(Init::WINDOW_WIDTH, Init::WINDOW_HEIGHT);
        setWindowTitle(tr("Fenêtre Principale"));
     
        Button();
     
        Slots();
    }
     
    //############### Private functions ###############
    void MainWindow::Button()
    {
        logo = new QPushButton(QIcon("pictures/logo.png"), "", this);
        logo->setIconSize(QSize(Init::LOGO_WIDTH, Init::LOGO_HEIGHT));
        logo->setGeometry(Init::LOGO_X, Init::LOGO_Y, Init::LOGO_WIDTH, Init::LOGO_HEIGHT);
        logo->setFlat(true);
     
        brotherButton = new QPushButton(QIcon("pictures/brother.png"), "", this);
        brotherButton->setGeometry(Init::MARK_COL_1, Init::MARK_LIN_1, Init::MARK_WIDTH, Init::MARK_HEIGHT);
        brotherButton->setIconSize(QSize(Init::MARK_WIDTH, Init::MARK_HEIGHT));
        brotherButton->setFlat(true);
     
        canonButton = new QPushButton(QIcon("pictures/canon.png"), "", this);
        canonButton->setGeometry(Init::MARK_COL_2, Init::MARK_LIN_1, Init::MARK_WIDTH, Init::MARK_HEIGHT);
        canonButton->setIconSize(QSize(Init::MARK_WIDTH, Init::MARK_HEIGHT));
        canonButton->setFlat(true);
     
        epsonButton = new QPushButton(QIcon("pictures/epson.png"), "", this);
        epsonButton->setGeometry(Init::MARK_COL_1, Init::MARK_LIN_2, Init::MARK_WIDTH, Init::MARK_HEIGHT);
        epsonButton->setIconSize(QSize(Init::MARK_WIDTH, Init::MARK_HEIGHT));
        epsonButton->setFlat(true);
     
        hpButton = new QPushButton(QIcon("pictures/hp.png"), "", this);
        hpButton->setGeometry(Init::MARK_COL_2, Init::MARK_LIN_2, Init::MARK_WIDTH, Init::MARK_HEIGHT);
        hpButton->setIconSize(QSize(Init::MARK_WIDTH, Init::MARK_HEIGHT));
        hpButton->setFlat(true);
     
        lexmarkButton = new QPushButton(QIcon("pictures/lexmark.png"), "", this);
        lexmarkButton->setGeometry(Init::MARK_COL_1, Init::MARK_LIN_3, Init::MARK_WIDTH, Init::MARK_HEIGHT);
        lexmarkButton->setIconSize(QSize(Init::MARK_WIDTH, Init::MARK_HEIGHT));
        lexmarkButton->setFlat(true);
     
        samsungButton = new QPushButton(QIcon("pictures/samsung.png"), "", this);
        samsungButton->setGeometry(Init::MARK_COL_2, Init::MARK_LIN_3, Init::MARK_WIDTH, Init::MARK_HEIGHT);
        samsungButton->setIconSize(QSize(Init::MARK_WIDTH, Init::MARK_HEIGHT));
        samsungButton->setFlat(true);
    }
     
    void MainWindow::Slots()
    {
        connect(brotherButton, SIGNAL(clicked()), this, SLOT(runBrother()));
        connect(canonButton, SIGNAL(clicked()), this, SLOT(runCanon()));
        connect(epsonButton, SIGNAL(clicked()), this, SLOT(runEpson()));
        connect(hpButton, SIGNAL(clicked()), this, SLOT(runHp()));
        connect(lexmarkButton, SIGNAL(clicked()), this, SLOT(runLexmark()));
        connect(samsungButton, SIGNAL(clicked()), this, SLOT(runSamsung()));
    }
     
    //############### Private slots ###############
    void MainWindow::runBrother()
    {
        brotherTypeWindow.show();
    }
     
    void MainWindow::runCanon()
    {
        canonTypeWindow.show();
    }
     
    void MainWindow::runEpson()
    {
        epsonTypeWindow.show();
    }
     
    void MainWindow::runHp()
    {
        hpTypeWindow.show();
    }
     
    void MainWindow::runLexmark()
    {
        lexmarkTypeWindow.show();
    }
     
    void MainWindow::runSamsung()
    {
        samsungTypeWindow.show();
    }
    La page du choix de type pour Brother :
    BrotherTypeWindow.h
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    #ifndef BROTHERTYPEWINDOW
    #define BROTHERTYPEWINDOW
     
    #include <QtWidgets>
    #include "Init.h"
    #include "BrotherHomeWindow.h"
    #include "BrotherLaserHomeWindow.h"
     
    class BrotherTypeWindow : public QWidget
    {
        Q_OBJECT
     
        public:
        BrotherTypeWindow();
     
        private slots:
        void RunInk();
        void RunLaser();
     
        private:
        QPushButton *exitButton;
        QPushButton *type1Button;
        QPushButton *type2Button;
     
        QPushButton *logo;
        QPushButton *markPic;
     
        BrotherHomeWindow brotherHomeWindow;
        BrotherLaserHomeWindow brotherLaserHomeWindow;
     
        void Button();
        void Slots();
    };
     
    #endif // BROTHERTYPEWINDOW
    BrotherTypeWindow.cpp
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    #include "BrotherTypeWindow.h"
     
    BrotherTypeWindow::BrotherTypeWindow() : QWidget()
    {
        setMinimumSize(Init::WINDOW_WIDTH, Init::WINDOW_HEIGHT);
        setMaximumSize(Init::WINDOW_WIDTH, Init::WINDOW_HEIGHT);
        setWindowTitle(tr("Brother"));
     
        Button();
        Slots();
    }
     
    //############### Private functions ###############
    void BrotherTypeWindow::Button()
    {
        logo = new QPushButton(QIcon("pictures/logo.png"), "", this);
        logo->setIconSize(QSize(Init::LOGO_WIDTH, Init::LOGO_HEIGHT));
        logo->setGeometry(Init::LOGO_X, Init::LOGO_Y, Init::LOGO_WIDTH, Init::LOGO_HEIGHT);
        logo->setFlat(true);
     
        markPic = new QPushButton(QIcon("pictures/brother.png"), "", this);
        markPic->setIconSize(QSize(Init::MARK_WIDTH, Init::MARK_HEIGHT));
        markPic->setGeometry(Init::MARK_CENTER_X, Init::MARK_CENTER_Y, Init::MARK_WIDTH, Init::MARK_HEIGHT);
        markPic->setFlat(true);
     
        type1Button = new QPushButton("Jet d'encre", this);
        type1Button->setGeometry(Init::TYPE_COL_1, Init::TYPE_LIN_1, Init::TYPE_WIDTH, Init::TYPE_HEIGHT);
        type1Button->setFont(Init::FONT1);
     
        type2Button = new QPushButton("Laser", this);
        type2Button->setGeometry(Init::TYPE_COL_1, Init::TYPE_LIN_2, Init::TYPE_WIDTH, Init::TYPE_HEIGHT);
        type2Button->setFont(Init::FONT1);
     
        exitButton = new QPushButton(QIcon("pictures/back.png"), "", this);
        exitButton->setGeometry(Init::EXIT_X, Init::EXIT_Y, Init::EXIT_WIDTH, Init::EXIT_HEIGHT);
        exitButton->setIconSize(QSize(Init::EXIT_WIDTH, Init::EXIT_HEIGHT));
    }
     
    void BrotherTypeWindow::Slots()
    {
        connect(exitButton, SIGNAL(clicked()), this, SLOT(close()));
        connect(type1Button, SIGNAL(clicked()), this, SLOT(RunInk()));
        connect(type2Button, SIGNAL(clicked()), this, SLOT(RunLaser()));
    }
     
    //############### Private slots ###############
    void BrotherTypeWindow::RunInk()
    {
        close();
        brotherHomeWindow.show();
    }
     
    void BrotherTypeWindow::RunLaser()
    {
        close();
        brotherLaserHomeWindow.show();
    }
    La page du choix de famille pour brother -> encre
    BrotherHomeWindow.h
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    #ifndef BROTHERHOMEWINDOW
    #define BROTHERHOMEWINDOW
     
    #include <QtWidgets>
    #include "Init.h"
    #include "BrotherDCPSeriesWindow.h"
    #include "BrotherMFCSeriesWindow.h"
    #include "BrotherFAXSeriesWindow.h"
     
    class BrotherHomeWindow : public QWidget
    {
        Q_OBJECT
     
        public:
        BrotherHomeWindow();
     
        private slots:
        void RunDCP();
        void RunFAX();
        void RunMFC();
     
        private:
        QPushButton *exitButton;
        QPushButton *series1Button;
        QPushButton *series2Button;
        QPushButton *series3Button;
     
        QPushButton *logo;
        QPushButton *markPic;
     
        BrotherDCPSeriesWindow brotherDCPSeriesWindow;
        BrotherFAXSeriesWindow brotherFAXSeriesWindow;
        BrotherMFCSeriesWindow brotherMFCSeriesWindow;
     
        void Button();
        void Slots();
    };
     
    #endif // BROTHERHOMEWINDOW
    BrotherHomeWindow.cpp
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    #include "BrotherHomeWindow.h"
     
    BrotherHomeWindow::BrotherHomeWindow() : QWidget()
    {
        setMinimumSize(Init::WINDOW_WIDTH, Init::WINDOW_HEIGHT);
        setMaximumSize(Init::WINDOW_WIDTH, Init::WINDOW_HEIGHT);
        setWindowTitle(tr("Brother"));
     
        Button();
        Slots();
    }
     
    //############### Private functions ###############
    void BrotherHomeWindow::Button()
    {
        logo = new QPushButton(QIcon("pictures/logo.png"), "", this);
        logo->setIconSize(QSize(Init::LOGO_WIDTH, Init::LOGO_HEIGHT));
        logo->setGeometry(Init::LOGO_X, Init::LOGO_Y, Init::LOGO_WIDTH, Init::LOGO_HEIGHT);
        logo->setFlat(true);
     
        markPic = new QPushButton(QIcon("pictures/brother.png"), "", this);
        markPic->setIconSize(QSize(Init::MARK_WIDTH, Init::MARK_HEIGHT));
        markPic->setGeometry(Init::MARK_CENTER_X, Init::MARK_CENTER_Y, Init::MARK_WIDTH, Init::MARK_HEIGHT);
        markPic->setFlat(true);
     
        series1Button = new QPushButton;
        series1Button->setGeometry(Init::HOME_COL_1, Init::HOME_LIN_1, Init::HOME_WIDTH, Init::HOME_HEIGHT);
        series1Button->setText("Série DCP");
        series1Button->setFont(Init::FONT6);
        series1Button->setParent(this);
     
        series2Button = new QPushButton;
        series2Button->setGeometry(Init::HOME_COL_2, Init::HOME_LIN_1, Init::HOME_WIDTH, Init::HOME_HEIGHT);
        series2Button->setText("Série FAX");
        series2Button->setFont(Init::FONT6);
        series2Button->setParent(this);
     
        series3Button = new QPushButton;
        series3Button->setGeometry(Init::HOME_COL_1, Init::HOME_LIN_2, Init::HOME_WIDTH, Init::HOME_HEIGHT);
        series3Button->setText("Série MFC");
        series3Button->setFont(Init::FONT6);
        series3Button->setParent(this);
     
        exitButton = new QPushButton(QIcon("pictures/back.png"), "", this);
        exitButton->setGeometry(Init::EXIT_X, Init::EXIT_Y, Init::EXIT_WIDTH, Init::EXIT_HEIGHT);
        exitButton->setIconSize(QSize(Init::EXIT_WIDTH, Init::EXIT_HEIGHT));
    }
     
    void BrotherHomeWindow::Slots()
    {
        connect(exitButton, SIGNAL(clicked()), this, SLOT(close()));
        connect(series1Button, SIGNAL(clicked()), this, SLOT(RunDCP()));
        connect(series2Button, SIGNAL(clicked()), this, SLOT(RunFAX()));
        connect(series3Button, SIGNAL(clicked()), this, SLOT(RunMFC()));
    }
     
    //############### Private slots ###############
    void BrotherHomeWindow::RunDCP()
    {
        close();
        brotherDCPSeriesWindow.show();
    }
     
    void BrotherHomeWindow::RunFAX()
    {
        close();
        brotherFAXSeriesWindow.show();
    }
     
    void BrotherHomeWindow::RunMFC()
    {
        close();
        brotherMFCSeriesWindow.show();
    }
    La page de sélection du modèle pour la première famille :
    BrotherDCPSeriesWindow.h
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    #ifndef BROTHERDCPSERIESWINDOW
    #define BROTHERDCPSERIESWINDOW
     
    #include <QtWidgets>
    #include "Init.h"
    #include "FinalWindow.h"
     
    class BrotherDCPSeriesWindow : public QWidget
    {
        Q_OBJECT
     
        public:
        BrotherDCPSeriesWindow();
     
        private slots:
        void NextClicked();
        void PreviousClicked();
        void Button1Clicked();
        void Button2Clicked();
        void Button3Clicked();
        void Button4Clicked();
        void Button5Clicked();
        void Button6Clicked();
        void Button7Clicked();
        void Button8Clicked();
        void Button9Clicked();
        void Button10Clicked();
        void Button11Clicked();
        void Button12Clicked();
        void Button13Clicked();
        void Button14Clicked();
        void Button15Clicked();
        void Button16Clicked();
        void Button17Clicked();
        void Button18Clicked();
        void Button19Clicked();
        void Button20Clicked();
        void Button21Clicked();
        void Button22Clicked();
        void Button23Clicked();
        void Button24Clicked();
        void Button25Clicked();
        void Button26Clicked();
        void Button27Clicked();
        void Button28Clicked();
        void Button29Clicked();
        void Button30Clicked();
     
        private:
        int myPage = 1;
     
        QPushButton *exitButton;
        QPushButton *nextButton;
        QPushButton *previousButton;
        QPushButton *Button1;
        QPushButton *Button2;
        QPushButton *Button3;
        QPushButton *Button4;
        QPushButton *Button5;
        QPushButton *Button6;
        QPushButton *Button7;
        QPushButton *Button8;
        QPushButton *Button9;
        QPushButton *Button10;
        QPushButton *Button11;
        QPushButton *Button12;
        QPushButton *Button13;
        QPushButton *Button14;
        QPushButton *Button15;
        QPushButton *Button16;
        QPushButton *Button17;
        QPushButton *Button18;
        QPushButton *Button19;
        QPushButton *Button20;
        QPushButton *Button21;
        QPushButton *Button22;
        QPushButton *Button23;
        QPushButton *Button24;
        QPushButton *Button25;
        QPushButton *Button26;
        QPushButton *Button27;
        QPushButton *Button28;
        QPushButton *Button29;
        QPushButton *Button30;
     
        QPushButton *logo;
        QPushButton *markPic;
        QLabel *seriesLabel;
     
        FinalWindow finalWindow;
     
        void Button();
        void SetInfo();
        void Slots();
        void RunFinal(std::string model);
    };
     
    #endif // BROTHERDCPSERIESWINDOW
    BrotherDCPSeriesWindow.cpp
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
    230
    231
    232
    233
    234
    235
    236
    237
    238
    239
    240
    241
    242
    243
    244
    245
    246
    247
    248
    249
    250
    251
    252
    253
    254
    255
    256
    257
    258
    259
    260
    261
    262
    263
    264
    265
    266
    267
    268
    269
    270
    271
    272
    273
    274
    275
    276
    277
    278
    279
    280
    281
    282
    283
    284
    285
    286
    287
    288
    289
    290
    291
    292
    293
    294
    295
    296
    297
    298
    299
    300
    301
    302
    303
    304
    305
    306
    307
    308
    309
    310
    311
    312
    313
    314
    315
    316
    317
    318
    319
    320
    321
    322
    323
    324
    325
    326
    327
    328
    329
    330
    331
    332
    333
    334
    335
    336
    337
    338
    339
    340
    341
    342
    343
    344
    345
    346
    347
    348
    349
    350
    351
    352
    353
    354
    355
    356
    357
    358
    359
    360
    361
    362
    363
    364
    365
    366
    367
    368
    369
    370
    371
    372
    373
    374
    375
    376
    377
    378
    379
    380
    381
    382
    383
    384
    385
    386
    387
    388
    389
    390
    391
    392
    393
    394
    395
    396
    397
    398
    399
    400
    401
    402
    403
    404
    405
    406
    407
    408
    409
    410
    411
    412
    413
    414
    415
    416
    417
    418
    419
    420
    421
    422
    423
    424
    425
    426
    427
    428
    429
    430
    431
    432
    433
    434
    435
    436
    437
    438
    439
    440
    441
    442
    443
    444
    445
    446
    447
    448
    449
    450
    451
    452
    453
    454
    455
    456
    457
    458
    459
    460
    461
    462
    463
    464
    465
    466
    467
    468
    469
    470
    471
    472
    473
    474
    475
    476
    477
    478
    479
    480
    481
    482
    483
    484
    485
    486
    487
    488
    489
    490
    491
    492
    493
    494
    495
    496
    497
    498
    499
    500
    501
    502
    503
    504
    505
    506
    507
    508
    509
    510
    511
    512
    513
    514
    515
    516
    517
    518
    519
    520
    521
    522
    523
    524
    525
    526
    527
    528
    529
    530
    531
    532
    533
    534
    535
    #include "BrotherDCPSeriesWindow.h"
     
    BrotherDCPSeriesWindow::BrotherDCPSeriesWindow() : QWidget()
    {
        setMinimumSize(Init::WINDOW_WIDTH, Init::WINDOW_HEIGHT);
        setMaximumSize(Init::WINDOW_WIDTH, Init::WINDOW_HEIGHT);
        setWindowTitle(tr("Brother - Série DCP"));
     
        Button();
        Slots();
    }
     
    //############### Private functions ###############
    void BrotherDCPSeriesWindow::Button()
    {
        logo = new QPushButton(QIcon("pictures/logo.png"), "", this);
        logo->setIconSize(QSize(Init::LOGO_WIDTH, Init::LOGO_HEIGHT));
        logo->setGeometry(Init::LOGO_X, Init::LOGO_Y, Init::LOGO_WIDTH, Init::LOGO_HEIGHT);
        logo->setFlat(true);
     
        markPic = new QPushButton(QIcon("pictures/brother.png"), "", this);
        markPic->setIconSize(QSize(Init::MARK_WIDTH, Init::MARK_HEIGHT));
        markPic->setGeometry(Init::MARK_SERIES_X, Init::MARK_SERIES_Y, Init::MARK_WIDTH, Init::MARK_HEIGHT);
        markPic->setFlat(true);
     
        seriesLabel = new QLabel("Série DCP", this);
        seriesLabel->setGeometry(Init::SERIES_LABEL_X, Init::SERIES_LABEL_Y, Init::MARK_WIDTH, Init::MARK_HEIGHT);
        seriesLabel->setFont(Init::FONT1);
        seriesLabel->setAlignment(Qt::AlignCenter);
     
        exitButton = new QPushButton(QIcon("pictures/back.png"), "", this);
        exitButton->setGeometry(Init::EXIT_X, Init::EXIT_Y, Init::EXIT_WIDTH, Init::EXIT_HEIGHT);
        exitButton->setIconSize(QSize(Init::EXIT_WIDTH, Init::EXIT_HEIGHT));
     
        nextButton = new QPushButton(QIcon("pictures/next.png"), "", this);
        nextButton->setGeometry(Init::EXIT_X - 75, Init::EXIT_Y, Init::EXIT_WIDTH, Init::EXIT_HEIGHT);
        nextButton->setIconSize(QSize(Init::EXIT_WIDTH, Init::EXIT_HEIGHT));
        nextButton->setFlat(true);
     
        previousButton = new QPushButton(QIcon("pictures/previous.png"), "", this);
        previousButton->setGeometry(Init::EXIT_X - 150, Init::EXIT_Y, Init::EXIT_WIDTH, Init::EXIT_HEIGHT);
        previousButton->setIconSize(QSize(Init::EXIT_WIDTH, Init::EXIT_HEIGHT));
        previousButton->setFlat(true);
     
        Button1 = new QPushButton(this);
        Button1->setGeometry(Init::MODEL_COL_1, Init::MODEL_LIN_1, Init::MODEL_WIDTH, Init::MODEL_HEIGHT);
        Button1->setFont(Init::FONT2);
     
        Button2 = new QPushButton(this);
        Button2->setGeometry(Init::MODEL_COL_2, Init::MODEL_LIN_1, Init::MODEL_WIDTH, Init::MODEL_HEIGHT);
        Button2->setFont(Init::FONT2);
     
        Button3 = new QPushButton(this);
        Button3->setGeometry(Init::MODEL_COL_3, Init::MODEL_LIN_1, Init::MODEL_WIDTH, Init::MODEL_HEIGHT);
        Button3->setFont(Init::FONT2);
     
        Button4 = new QPushButton(this);
        Button4->setGeometry(Init::MODEL_COL_4, Init::MODEL_LIN_1, Init::MODEL_WIDTH, Init::MODEL_HEIGHT);
        Button4->setFont(Init::FONT2);
     
        Button5 = new QPushButton(this);
        Button5->setGeometry(Init::MODEL_COL_5, Init::MODEL_LIN_1, Init::MODEL_WIDTH, Init::MODEL_HEIGHT);
        Button5->setFont(Init::FONT2);
     
        Button6 = new QPushButton(this);
        Button6->setGeometry(Init::MODEL_COL_1, Init::MODEL_LIN_2, Init::MODEL_WIDTH, Init::MODEL_HEIGHT);
        Button6->setFont(Init::FONT2);
     
        Button7 = new QPushButton(this);
        Button7->setGeometry(Init::MODEL_COL_2, Init::MODEL_LIN_2, Init::MODEL_WIDTH, Init::MODEL_HEIGHT);
        Button7->setFont(Init::FONT2);
     
        Button8 = new QPushButton(this);
        Button8->setGeometry(Init::MODEL_COL_3, Init::MODEL_LIN_2, Init::MODEL_WIDTH, Init::MODEL_HEIGHT);
        Button8->setFont(Init::FONT2);
     
        Button9 = new QPushButton(this);
        Button9->setGeometry(Init::MODEL_COL_4, Init::MODEL_LIN_2, Init::MODEL_WIDTH, Init::MODEL_HEIGHT);
        Button9->setFont(Init::FONT2);
     
        Button10 = new QPushButton(this);
        Button10->setGeometry(Init::MODEL_COL_5, Init::MODEL_LIN_2, Init::MODEL_WIDTH, Init::MODEL_HEIGHT);
        Button10->setFont(Init::FONT2);
     
        Button11 = new QPushButton(this);
        Button11->setGeometry(Init::MODEL_COL_1, Init::MODEL_LIN_3, Init::MODEL_WIDTH, Init::MODEL_HEIGHT);
        Button11->setFont(Init::FONT2);
     
        Button12 = new QPushButton(this);
        Button12->setGeometry(Init::MODEL_COL_2, Init::MODEL_LIN_3, Init::MODEL_WIDTH, Init::MODEL_HEIGHT);
        Button12->setFont(Init::FONT2);
     
        Button13 = new QPushButton(this);
        Button13->setGeometry(Init::MODEL_COL_3, Init::MODEL_LIN_3, Init::MODEL_WIDTH, Init::MODEL_HEIGHT);
        Button13->setFont(Init::FONT2);
     
        Button14 = new QPushButton(this);
        Button14->setGeometry(Init::MODEL_COL_4, Init::MODEL_LIN_3, Init::MODEL_WIDTH, Init::MODEL_HEIGHT);
        Button14->setFont(Init::FONT2);
     
        Button15 = new QPushButton(this);
        Button15->setGeometry(Init::MODEL_COL_5, Init::MODEL_LIN_3, Init::MODEL_WIDTH, Init::MODEL_HEIGHT);
        Button15->setFont(Init::FONT2);
     
        Button16 = new QPushButton(this);
        Button16->setGeometry(Init::MODEL_COL_1, Init::MODEL_LIN_4, Init::MODEL_WIDTH, Init::MODEL_HEIGHT);
        Button16->setFont(Init::FONT2);
     
        Button17 = new QPushButton(this);
        Button17->setGeometry(Init::MODEL_COL_2, Init::MODEL_LIN_4, Init::MODEL_WIDTH, Init::MODEL_HEIGHT);
        Button17->setFont(Init::FONT2);
     
        Button18 = new QPushButton(this);
        Button18->setGeometry(Init::MODEL_COL_3, Init::MODEL_LIN_4, Init::MODEL_WIDTH, Init::MODEL_HEIGHT);
        Button18->setFont(Init::FONT2);
     
        Button19 = new QPushButton(this);
        Button19->setGeometry(Init::MODEL_COL_4, Init::MODEL_LIN_4, Init::MODEL_WIDTH, Init::MODEL_HEIGHT);
        Button19->setFont(Init::FONT2);
     
        Button20 = new QPushButton(this);
        Button20->setGeometry(Init::MODEL_COL_5, Init::MODEL_LIN_4, Init::MODEL_WIDTH, Init::MODEL_HEIGHT);
        Button20->setFont(Init::FONT2);
     
        Button21 = new QPushButton(this);
        Button21->setGeometry(Init::MODEL_COL_1, Init::MODEL_LIN_5, Init::MODEL_WIDTH, Init::MODEL_HEIGHT);
        Button21->setFont(Init::FONT2);
     
        Button22 = new QPushButton(this);
        Button22->setGeometry(Init::MODEL_COL_2, Init::MODEL_LIN_5, Init::MODEL_WIDTH, Init::MODEL_HEIGHT);
        Button22->setFont(Init::FONT2);
     
        Button23 = new QPushButton(this);
        Button23->setGeometry(Init::MODEL_COL_3, Init::MODEL_LIN_5, Init::MODEL_WIDTH, Init::MODEL_HEIGHT);
        Button23->setFont(Init::FONT2);
     
        Button24 = new QPushButton(this);
        Button24->setGeometry(Init::MODEL_COL_4, Init::MODEL_LIN_5, Init::MODEL_WIDTH, Init::MODEL_HEIGHT);
        Button24->setFont(Init::FONT2);
     
        Button25 = new QPushButton(this);
        Button25->setGeometry(Init::MODEL_COL_5, Init::MODEL_LIN_5, Init::MODEL_WIDTH, Init::MODEL_HEIGHT);
        Button25->setFont(Init::FONT2);
     
        Button26 = new QPushButton(this);
        Button26->setGeometry(Init::MODEL_COL_1, Init::MODEL_LIN_6, Init::MODEL_WIDTH, Init::MODEL_HEIGHT);
        Button26->setFont(Init::FONT2);
     
        Button27 = new QPushButton(this);
        Button27->setGeometry(Init::MODEL_COL_2, Init::MODEL_LIN_6, Init::MODEL_WIDTH, Init::MODEL_HEIGHT);
        Button27->setFont(Init::FONT2);
     
        Button28 = new QPushButton(this);
        Button28->setGeometry(Init::MODEL_COL_3, Init::MODEL_LIN_6, Init::MODEL_WIDTH, Init::MODEL_HEIGHT);
        Button28->setFont(Init::FONT2);
     
        Button29 = new QPushButton(this);
        Button29->setGeometry(Init::MODEL_COL_4, Init::MODEL_LIN_6, Init::MODEL_WIDTH, Init::MODEL_HEIGHT);
        Button29->setFont(Init::FONT2);
     
        Button30 = new QPushButton(this);
        Button30->setGeometry(Init::MODEL_COL_5, Init::MODEL_LIN_6, Init::MODEL_WIDTH, Init::MODEL_HEIGHT);
        Button30->setFont(Init::FONT2);
     
        SetInfo();
    }
     
    void BrotherDCPSeriesWindow::SetInfo()
    {
        if (myPage == 1)
        {
            nextButton->show();
            previousButton->hide();
            Button1->setText("105CN");
            Button2->setText("110C");
            Button3->setText("115C");
            Button4->setText("117C");
            Button5->setText("120C");
            Button6->setText("130C");
            Button7->setText("135C");
            Button8->setText("145C");
            Button9->setText("150C");
            Button10->setText("153C");
            Button11->setText("163C");
            Button12->setText("165C");
            Button13->setText("167C");
            Button14->setText("185C");
            Button15->setText("193C");
            Button16->setText("195C");
            Button17->setText("197C");
            Button18->setText("310C");
            Button19->setText("310CN");
            Button20->setText("315CN");
            Button21->setText("330C");
            Button22->setText("330CN");
            Button23->setText("340CW");
            Button24->setText("340DCW");
            Button25->setText("350C");
            Button26->setText("353C");
            Button27->setText("357C");
            Button28->setText("365CN");
            Button29->setText("373CW");
            Button30->setText("375CW");
            Button30->show();
        }
        else if (myPage == 2)
        {
            nextButton->hide();
            previousButton->show();
            Button1->setText("377CW");
            Button2->setText("383C");
            Button3->setText("385C");
            Button4->setText("387C");
            Button5->setText("395CN");
            Button6->setText("540CN");
            Button7->setText("560CN");
            Button8->setText("585CW");
            Button9->setText("750CW");
            Button10->setText("770CW");
            Button11->setText("4020C");
            Button12->setText("6690CW");
            Button13->setText("J125");
            Button14->setText("J132W");
            Button15->setText("J140W");
            Button16->setText("J152W");
            Button17->setText("J172W");
            Button18->setText("J265W");
            Button19->setText("J315W");
            Button20->setText("J515W");
            Button21->setText("J525W");
            Button22->setText("J552DW");
            Button23->setText("J625DW");
            Button24->setText("J715W");
            Button25->setText("J725DW");
            Button26->setText("J752DW");
            Button27->setText("J925DW");
            Button28->setText("J4110DW");
            Button29->setText("J4120DW");
            Button30->hide();
        }
    }
     
    void BrotherDCPSeriesWindow::Slots()
    {
        connect(exitButton, SIGNAL(clicked()), this, SLOT(close()));
        connect(nextButton, SIGNAL(clicked()), this, SLOT(NextClicked()));
        connect(previousButton, SIGNAL(clicked()), this, SLOT(PreviousClicked()));
        connect(Button1, SIGNAL(clicked()), this, SLOT(Button1Clicked()));
        connect(Button2, SIGNAL(clicked()), this, SLOT(Button2Clicked()));
        connect(Button3, SIGNAL(clicked()), this, SLOT(Button3Clicked()));
        connect(Button4, SIGNAL(clicked()), this, SLOT(Button4Clicked()));
        connect(Button5, SIGNAL(clicked()), this, SLOT(Button5Clicked()));
        connect(Button6, SIGNAL(clicked()), this, SLOT(Button6Clicked()));
        connect(Button7, SIGNAL(clicked()), this, SLOT(Button7Clicked()));
        connect(Button8, SIGNAL(clicked()), this, SLOT(Button8Clicked()));
        connect(Button9, SIGNAL(clicked()), this, SLOT(Button9Clicked()));
        connect(Button10, SIGNAL(clicked()), this, SLOT(Button10Clicked()));
        connect(Button11, SIGNAL(clicked()), this, SLOT(Button11Clicked()));
        connect(Button12, SIGNAL(clicked()), this, SLOT(Button12Clicked()));
        connect(Button13, SIGNAL(clicked()), this, SLOT(Button13Clicked()));
        connect(Button14, SIGNAL(clicked()), this, SLOT(Button14Clicked()));
        connect(Button15, SIGNAL(clicked()), this, SLOT(Button15Clicked()));
        connect(Button16, SIGNAL(clicked()), this, SLOT(Button16Clicked()));
        connect(Button17, SIGNAL(clicked()), this, SLOT(Button17Clicked()));
        connect(Button18, SIGNAL(clicked()), this, SLOT(Button18Clicked()));
        connect(Button19, SIGNAL(clicked()), this, SLOT(Button19Clicked()));
        connect(Button20, SIGNAL(clicked()), this, SLOT(Button20Clicked()));
        connect(Button21, SIGNAL(clicked()), this, SLOT(Button21Clicked()));
        connect(Button22, SIGNAL(clicked()), this, SLOT(Button22Clicked()));
        connect(Button23, SIGNAL(clicked()), this, SLOT(Button23Clicked()));
        connect(Button24, SIGNAL(clicked()), this, SLOT(Button24Clicked()));
        connect(Button25, SIGNAL(clicked()), this, SLOT(Button25Clicked()));
        connect(Button26, SIGNAL(clicked()), this, SLOT(Button26Clicked()));
        connect(Button27, SIGNAL(clicked()), this, SLOT(Button27Clicked()));
        connect(Button28, SIGNAL(clicked()), this, SLOT(Button28Clicked()));
        connect(Button29, SIGNAL(clicked()), this, SLOT(Button29Clicked()));
        connect(Button30, SIGNAL(clicked()), this, SLOT(Button30Clicked()));
    }
     
    void BrotherDCPSeriesWindow::RunFinal(std::string model)
    {
        close();
        finalWindow.show();
        finalWindow.SetInfos(model, "brother");
    }
     
    //############### Private slots ###############
    void BrotherDCPSeriesWindow::NextClicked()
    {
        myPage++;
        SetInfo();
    }
     
    void BrotherDCPSeriesWindow::PreviousClicked()
    {
        myPage--;
        SetInfo();
    }
     
    void BrotherDCPSeriesWindow::Button1Clicked()
    {
        if (myPage == 1)
            RunFinal("DCP-105CN");
        else if (myPage == 2)
            RunFinal("DCP-377CW");
    }
     
    void BrotherDCPSeriesWindow::Button2Clicked()
    {
        if (myPage == 1)
            RunFinal("DCP-110C");
        else if (myPage == 2)
            RunFinal("DCP-383C");
    }
     
    void BrotherDCPSeriesWindow::Button3Clicked()
    {
        if (myPage == 1)
            RunFinal("DCP-115C");
        else if (myPage == 2)
            RunFinal("DCP-385C");
    }
     
    void BrotherDCPSeriesWindow::Button4Clicked()
    {
        if (myPage == 1)
            RunFinal("DCP-117C");
        else if (myPage == 2)
            RunFinal("DCP-387C");
    }
     
    void BrotherDCPSeriesWindow::Button5Clicked()
    {
        if (myPage == 1)
            RunFinal("DCP-120C");
        else if (myPage == 2)
            RunFinal("DCP-395CN");
    }
     
    void BrotherDCPSeriesWindow::Button6Clicked()
    {
        if (myPage == 1)
            RunFinal("DCP-130C");
        else if (myPage == 2)
            RunFinal("DCP-540CN");
    }
     
    void BrotherDCPSeriesWindow::Button7Clicked()
    {
        if (myPage == 1)
            RunFinal("DCP-135C");
        else if (myPage == 2)
            RunFinal("DCP-560CN");
    }
     
    void BrotherDCPSeriesWindow::Button8Clicked()
    {
        if (myPage == 1)
            RunFinal("DCP-145C");
        else if (myPage == 2)
            RunFinal("DCP-585CW");
    }
     
    void BrotherDCPSeriesWindow::Button9Clicked()
    {
        if (myPage == 1)
            RunFinal("DCP-150C");
        else if (myPage == 2)
            RunFinal("DCP-750CW");
    }
     
    void BrotherDCPSeriesWindow::Button10Clicked()
    {
        if (myPage == 1)
            RunFinal("DCP-153C");
        else if (myPage == 2)
            RunFinal("DCP-770CW");
    }
     
    void BrotherDCPSeriesWindow::Button11Clicked()
    {
        if (myPage == 1)
            RunFinal("DCP-163C");
        else if (myPage == 2)
            RunFinal("DCP-4020C");
    }
     
    void BrotherDCPSeriesWindow::Button12Clicked()
    {
        if (myPage == 1)
            RunFinal("DCP-165C");
        else if (myPage == 2)
            RunFinal("DCP-6690CW");
    }
     
    void BrotherDCPSeriesWindow::Button13Clicked()
    {
        if (myPage == 1)
            RunFinal("DCP-167C");
        else if (myPage == 2)
            RunFinal("DCP-J125");
    }
     
    void BrotherDCPSeriesWindow::Button14Clicked()
    {
        if (myPage == 1)
            RunFinal("DCP-185C");
        else if (myPage == 2)
            RunFinal("DCP-J132W");
    }
     
    void BrotherDCPSeriesWindow::Button15Clicked()
    {
        if (myPage == 1)
            RunFinal("DCP-193C");
        else if (myPage == 2)
            RunFinal("DCP-J140W");
    }
     
    void BrotherDCPSeriesWindow::Button16Clicked()
    {
        if (myPage == 1)
            RunFinal("DCP-195C");
        else if (myPage == 2)
            RunFinal("DCP-J152W");
    }
     
    void BrotherDCPSeriesWindow::Button17Clicked()
    {
        if (myPage == 1)
            RunFinal("DCP-197C");
        else if (myPage == 2)
            RunFinal("DCP-J172W");
    }
     
    void BrotherDCPSeriesWindow::Button18Clicked()
    {
        if (myPage == 1)
            RunFinal("DCP-310C");
        else if (myPage == 2)
            RunFinal("DCP-J265W");
    }
     
    void BrotherDCPSeriesWindow::Button19Clicked()
    {
        if (myPage == 1)
            RunFinal("DCP-310CN");
        else if (myPage == 2)
            RunFinal("DCP-J315W");
    }
     
    void BrotherDCPSeriesWindow::Button20Clicked()
    {
        if (myPage == 1)
            RunFinal("DCP-315CN");
        else if (myPage == 2)
            RunFinal("DCP-J515W");
    }
     
    void BrotherDCPSeriesWindow::Button21Clicked()
    {
        if (myPage == 1)
            RunFinal("DCP-330C");
        else if (myPage == 2)
            RunFinal("DCP-J525W");
    }
     
    void BrotherDCPSeriesWindow::Button22Clicked()
    {
        if (myPage == 1)
            RunFinal("DCP-330CN");
        else if (myPage == 2)
            RunFinal("DCP-J552DW");
    }
     
    void BrotherDCPSeriesWindow::Button23Clicked()
    {
        if (myPage == 1)
            RunFinal("DCP-340CW");
        else if (myPage == 2)
            RunFinal("DCP-J625DW");
    }
     
    void BrotherDCPSeriesWindow::Button24Clicked()
    {
        if (myPage == 1)
            RunFinal("DCP-340DCW");
        else if (myPage == 2)
            RunFinal("DCP-J715W");
    }
     
    void BrotherDCPSeriesWindow::Button25Clicked()
    {
        if (myPage == 1)
            RunFinal("DCP-350C");
        else if (myPage == 2)
            RunFinal("DCP-J725DW");
    }
     
    void BrotherDCPSeriesWindow::Button26Clicked()
    {
        if (myPage == 1)
            RunFinal("DCP-353C");
        else if (myPage == 2)
            RunFinal("DCP-J752DW");
    }
     
    void BrotherDCPSeriesWindow::Button27Clicked()
    {
        if (myPage == 1)
            RunFinal("DCP-357C");
        else if (myPage == 2)
            RunFinal("DCP-J925DW");
    }
     
    void BrotherDCPSeriesWindow::Button28Clicked()
    {
        if (myPage == 1)
            RunFinal("DCP-365CN");
        else if (myPage == 2)
            RunFinal("DCP-J4110DW");
    }
     
    void BrotherDCPSeriesWindow::Button29Clicked()
    {
        if (myPage == 1)
            RunFinal("DCP-373CW");
        else if (myPage == 2)
            RunFinal("DCP-J4120DW");
    }
     
    void BrotherDCPSeriesWindow::Button30Clicked()
    {
        RunFinal("DCP-375CW");
    }
    Et enfin la page finale qui affiche les références des cartouches :
    FinalWindow.h
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    #ifndef FINALWINDOW
    #define FINALWINDOW
     
    #include <QtWidgets>
    #include <fstream>
    #include "Init.h"
     
    class FinalWindow : public QWidget
     
    {
        Q_OBJECT
     
        public:
        FinalWindow();
        void SetInfos(std::string model, std::string mark);
     
        private slots:
     
        private:
        QPushButton *exitButton;
     
        QPushButton *logo;
        QPushButton *markPic;
        QLabel *modelLabel;
     
        // 1st line labels
        QLabel *typeLabel;
        QLabel *blackLabel;
        QLabel *magentaLabel;
        QLabel *cyanLabel;
        QLabel *yellowLabel;
        QLabel *capacityLabel;
     
        // 2nd line labels
        QLabel *refNorm;
        QLabel *refBlack;
        QLabel *refMagenta;
        QLabel *refCyan;
        QLabel *refYellow;
        QLabel *normalLabel;
     
        // 3rd line labels
        QLabel *nPageNorm;
        QLabel *nPageBlack;
        QLabel *nPageMagenta;
        QLabel *nPageCyan;
        QLabel *nPageYellow;
     
        // 4th line labels
        QLabel *refXL;
        QLabel *refBlackXL;
        QLabel *refMagentaXL;
        QLabel *refCyanXL;
        QLabel *refYellowXL;
        QLabel *XLLabel;
     
        // 5th line labels
        QLabel *nPageXL;
        QLabel *nPageBlackXL;
        QLabel *nPageMagentaXL;
        QLabel *nPageCyanXL;
        QLabel *nPageYellowXL;
     
        // 6th line labels
        QLabel *refXXL;
        QLabel *refBlackXXL;
        QLabel *refMagentaXXL;
        QLabel *refCyanXXL;
        QLabel *refYellowXXL;
        QLabel *XXLLabel;
     
        // 7th line labels
        QLabel *nPageXXL;
        QLabel *nPageBlackXXL;
        QLabel *nPageMagentaXXL;
        QLabel *nPageCyanXXL;
        QLabel *nPageYellowXXL;
     
        // 8th line labels
        QLabel *infoLabel1;
     
        void Button();
        void Slots();
        std::string ReadInfos(std::ifstream &file);
        void SearchInfos(std::ifstream &file, std::string model);
        void AssignInfos(std::ifstream &file);
    };
     
    #endif // FINALWINDOW
    FinalWindow.cpp
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
    230
    231
    232
    233
    234
    235
    236
    237
    238
    239
    240
    241
    242
    243
    244
    245
    246
    247
    248
    249
    250
    251
    252
    253
    254
    255
    256
    257
    258
    259
    260
    261
    262
    263
    264
    265
    266
    267
    268
    269
    270
    271
    272
    273
    274
    275
    276
    277
    278
    279
    280
    281
    282
    283
    284
    285
    286
    287
    288
    289
    290
    291
    292
    293
    294
    295
    296
    297
    298
    299
    300
    301
    302
    303
    304
    305
    306
    307
    308
    309
    310
    311
    312
    313
    314
    315
    316
    317
    318
    319
    320
    321
    322
    323
    324
    325
    326
    327
    328
    329
    330
    331
    #include "FinalWindow.h"
     
    FinalWindow::FinalWindow() : QWidget()
    {
        setMinimumSize(Init::WINDOW_WIDTH, Init::WINDOW_HEIGHT);
        setMaximumSize(Init::WINDOW_WIDTH, Init::WINDOW_HEIGHT);
        setWindowTitle(tr("Final"));
     
        Button();
        Slots();
    }
     
    void FinalWindow::SetInfos(std::string model, std::string mark)
    {
        modelLabel->setText(QString::fromStdString(model));
        markPic->setIcon(QIcon(QString::fromStdString("pictures/" + mark + ".png")));
     
        std::ifstream file("database.txt");
        SearchInfos(file, model);
    }
     
    //############### Private functions ###############
    void FinalWindow::Button()
    {
        logo = new QPushButton(QIcon("pictures/logo.png"), "", this);
        logo->setIconSize(QSize(Init::LOGO_WIDTH, Init::LOGO_HEIGHT));
        logo->setGeometry(Init::LOGO_X, Init::LOGO_Y, Init::LOGO_WIDTH, Init::LOGO_HEIGHT);
        logo->setFlat(true);
     
        markPic = new QPushButton;
        markPic->setIconSize(QSize(Init::MARK_WIDTH, Init::MARK_HEIGHT));
        markPic->setGeometry(Init::MARK_SERIES_X, Init::MARK_SERIES_Y, Init::MARK_WIDTH, Init::MARK_HEIGHT);
        markPic->setParent(this);
        markPic->setFlat(true);
     
        modelLabel = new QLabel(this);
        modelLabel->setGeometry(Init::SERIES_LABEL_X, Init::SERIES_LABEL_Y, Init::FINAL_LABEL_WIDTH, Init::FINAL_LABEL_HEIGHT);
        modelLabel->setFont(Init::FONT3);
        modelLabel->setAlignment(Qt::AlignCenter);
     
        // 1st line labels
        typeLabel = new QLabel(this);
        typeLabel->setGeometry(Init::FINAL_COL_1, Init::FINAL_LIN_1, Init::FINAL_WIDTH, Init::FINAL_HEIGHT);
        typeLabel->setFont(Init::FONT4);
        typeLabel->setAlignment(Qt::AlignCenter);
     
        blackLabel = new QLabel(tr("Noir"), this);
        blackLabel->setGeometry(Init::FINAL_COL_2, Init::FINAL_LIN_1, Init::FINAL_WIDTH, Init::FINAL_HEIGHT);
        blackLabel->setFont(Init::FONT2);
        blackLabel->setAlignment(Qt::AlignCenter);
        blackLabel->setStyleSheet("QLabel { background-color : black; color : white}");
     
        magentaLabel = new QLabel(tr("Magenta"), this);
        magentaLabel->setGeometry(Init::FINAL_COL_3, Init::FINAL_LIN_1, Init::FINAL_WIDTH, Init::FINAL_HEIGHT);
        magentaLabel->setFont(Init::FONT2);
        magentaLabel->setAlignment(Qt::AlignCenter);
        magentaLabel->setStyleSheet("QLabel { background-color : magenta}");
     
        cyanLabel = new QLabel(tr("Cyan"), this);
        cyanLabel->setGeometry(Init::FINAL_COL_4, Init::FINAL_LIN_1, Init::FINAL_WIDTH, Init::FINAL_HEIGHT);
        cyanLabel->setFont(Init::FONT2);
        cyanLabel->setAlignment(Qt::AlignCenter);
        cyanLabel->setStyleSheet("QLabel { background-color : cyan}");
     
        yellowLabel = new QLabel(tr("Jaune"), this);
        yellowLabel->setGeometry(Init::FINAL_COL_5, Init::FINAL_LIN_1, Init::FINAL_WIDTH, Init::FINAL_HEIGHT);
        yellowLabel->setFont(Init::FONT2);
        yellowLabel->setAlignment(Qt::AlignCenter);
        yellowLabel->setStyleSheet("QLabel { background-color : yellow}");
     
        capacityLabel = new QLabel(tr("Type"), this);
        capacityLabel->setGeometry(Init::FINAL_COL_6, Init::FINAL_LIN_1, Init::FINAL_WIDTH, Init::FINAL_HEIGHT);
        capacityLabel->setFont(Init::FONT2);
        capacityLabel->setAlignment(Qt::AlignCenter);
     
        // 2nd line labels
        refNorm = new QLabel(tr("Référence :"), this);
        refNorm->setGeometry(Init::FINAL_COL_1, Init::FINAL_LIN_2, Init::FINAL_WIDTH, Init::FINAL_HEIGHT);
        refNorm->setFont(Init::FONT2);
        refNorm->setAlignment(Qt::AlignCenter);
     
        refBlack = new QLabel(this);
        refBlack->setGeometry(Init::FINAL_COL_2, Init::FINAL_LIN_2, Init::FINAL_WIDTH, Init::FINAL_HEIGHT);
        refBlack->setFont(Init::FONT2);
        refBlack->setAlignment(Qt::AlignCenter);
        refBlack->setStyleSheet("QLabel { background-color : black; color : white}");
     
        refMagenta = new QLabel(this);
        refMagenta->setGeometry(Init::FINAL_COL_3, Init::FINAL_LIN_2, Init::FINAL_WIDTH, Init::FINAL_HEIGHT);
        refMagenta->setFont(Init::FONT2);
        refMagenta->setAlignment(Qt::AlignCenter);
        refMagenta->setStyleSheet("QLabel { background-color : magenta}");
     
        refCyan = new QLabel(this);
        refCyan->setGeometry(Init::FINAL_COL_4, Init::FINAL_LIN_2, Init::FINAL_WIDTH, Init::FINAL_HEIGHT);
        refCyan->setFont(Init::FONT2);
        refCyan->setAlignment(Qt::AlignCenter);
        refCyan->setStyleSheet("QLabel { background-color : cyan}");
     
        refYellow = new QLabel(this);
        refYellow->setGeometry(Init::FINAL_COL_5, Init::FINAL_LIN_2, Init::FINAL_WIDTH, Init::FINAL_HEIGHT);
        refYellow->setFont(Init::FONT2);
        refYellow->setAlignment(Qt::AlignCenter);
        refYellow->setStyleSheet("QLabel { background-color : yellow}");
     
        normalLabel = new QLabel(tr("NORMAL"), this);
        normalLabel->setGeometry(Init::FINAL_COL_6, Init::FINAL_LIN_2, Init::FINAL_WIDTH, Init::FINAL_HEIGHT);
        normalLabel->setFont(Init::FONT2);
        normalLabel->setAlignment(Qt::AlignCenter);
     
        // 3rd line labels
        nPageNorm = new QLabel(tr("Nombre pages*"), this);
        nPageNorm->setGeometry(Init::FINAL_COL_1, Init::FINAL_LIN_3, Init::FINAL_WIDTH, Init::FINAL_HEIGHT);
        nPageNorm->setFont(Init::FONT2);
        nPageNorm->setAlignment(Qt::AlignCenter);
     
        nPageBlack = new QLabel(this);
        nPageBlack->setGeometry(Init::FINAL_COL_2, Init::FINAL_LIN_3, Init::FINAL_WIDTH, Init::FINAL_HEIGHT);
        nPageBlack->setFont(Init::FONT2);
        nPageBlack->setAlignment(Qt::AlignCenter);
     
        nPageMagenta = new QLabel(this);
        nPageMagenta->setGeometry(Init::FINAL_COL_3, Init::FINAL_LIN_3, Init::FINAL_WIDTH, Init::FINAL_HEIGHT);
        nPageMagenta->setFont(Init::FONT2);
        nPageMagenta->setAlignment(Qt::AlignCenter);
     
        nPageCyan = new QLabel(this);
        nPageCyan->setGeometry(Init::FINAL_COL_4, Init::FINAL_LIN_3, Init::FINAL_WIDTH, Init::FINAL_HEIGHT);
        nPageCyan->setFont(Init::FONT2);
        nPageCyan->setAlignment(Qt::AlignCenter);
     
        nPageYellow = new QLabel(this);
        nPageYellow->setGeometry(Init::FINAL_COL_5, Init::FINAL_LIN_3, Init::FINAL_WIDTH, Init::FINAL_HEIGHT);
        nPageYellow->setFont(Init::FONT2);
        nPageYellow->setAlignment(Qt::AlignCenter);
     
        // 4th line labels
        refXL = new QLabel(tr("Référence :"), this);
        refXL->setGeometry(Init::FINAL_COL_1, Init::FINAL_LIN_4, Init::FINAL_WIDTH, Init::FINAL_HEIGHT);
        refXL->setFont(Init::FONT2);
        refXL->setAlignment(Qt::AlignCenter);
     
        refBlackXL = new QLabel(this);
        refBlackXL->setGeometry(Init::FINAL_COL_2, Init::FINAL_LIN_4, Init::FINAL_WIDTH, Init::FINAL_HEIGHT);
        refBlackXL->setFont(Init::FONT2);
        refBlackXL->setAlignment(Qt::AlignCenter);
        refBlackXL->setStyleSheet("QLabel { background-color : black; color : white}");
     
        refMagentaXL = new QLabel(this);
        refMagentaXL->setGeometry(Init::FINAL_COL_3, Init::FINAL_LIN_4, Init::FINAL_WIDTH, Init::FINAL_HEIGHT);
        refMagentaXL->setFont(Init::FONT2);
        refMagentaXL->setAlignment(Qt::AlignCenter);
        refMagentaXL->setStyleSheet("QLabel { background-color : magenta}");
     
        refCyanXL = new QLabel(this);
        refCyanXL->setGeometry(Init::FINAL_COL_4, Init::FINAL_LIN_4, Init::FINAL_WIDTH, Init::FINAL_HEIGHT);
        refCyanXL->setFont(Init::FONT2);
        refCyanXL->setAlignment(Qt::AlignCenter);
        refCyanXL->setStyleSheet("QLabel { background-color : cyan}");
     
        refYellowXL = new QLabel(this);
        refYellowXL->setGeometry(Init::FINAL_COL_5, Init::FINAL_LIN_4, Init::FINAL_WIDTH, Init::FINAL_HEIGHT);
        refYellowXL->setFont(Init::FONT2);
        refYellowXL->setAlignment(Qt::AlignCenter);
        refYellowXL->setStyleSheet("QLabel { background-color : yellow}");
     
        XLLabel = new QLabel(tr("XL"), this);
        XLLabel->setGeometry(Init::FINAL_COL_6, Init::FINAL_LIN_4, Init::FINAL_WIDTH, Init::FINAL_HEIGHT);
        XLLabel->setFont(Init::FONT2);
        XLLabel->setAlignment(Qt::AlignCenter);
     
        // 5th line labels
        nPageXL = new QLabel(tr("Nombre pages*"), this);
        nPageXL->setGeometry(Init::FINAL_COL_1, Init::FINAL_LIN_5, Init::FINAL_WIDTH, Init::FINAL_HEIGHT);
        nPageXL->setFont(Init::FONT2);
        nPageXL->setAlignment(Qt::AlignCenter);
     
        nPageBlackXL = new QLabel(this);
        nPageBlackXL->setGeometry(Init::FINAL_COL_2, Init::FINAL_LIN_5, Init::FINAL_WIDTH, Init::FINAL_HEIGHT);
        nPageBlackXL->setFont(Init::FONT2);
        nPageBlackXL->setAlignment(Qt::AlignCenter);
     
        nPageMagentaXL = new QLabel(this);
        nPageMagentaXL->setGeometry(Init::FINAL_COL_3, Init::FINAL_LIN_5, Init::FINAL_WIDTH, Init::FINAL_HEIGHT);
        nPageMagentaXL->setFont(Init::FONT2);
        nPageMagentaXL->setAlignment(Qt::AlignCenter);
     
        nPageCyanXL = new QLabel(this);
        nPageCyanXL->setGeometry(Init::FINAL_COL_4, Init::FINAL_LIN_5, Init::FINAL_WIDTH, Init::FINAL_HEIGHT);
        nPageCyanXL->setFont(Init::FONT2);
        nPageCyanXL->setAlignment(Qt::AlignCenter);
     
        nPageYellowXL = new QLabel(this);
        nPageYellowXL->setGeometry(Init::FINAL_COL_5, Init::FINAL_LIN_5, Init::FINAL_WIDTH, Init::FINAL_HEIGHT);
        nPageYellowXL->setFont(Init::FONT2);
        nPageYellowXL->setAlignment(Qt::AlignCenter);
     
        // 6th line labels
        refXXL = new QLabel(tr("Référence :"), this);
        refXXL->setGeometry(Init::FINAL_COL_1, Init::FINAL_LIN_6, Init::FINAL_WIDTH, Init::FINAL_HEIGHT);
        refXXL->setFont(Init::FONT2);
        refXXL->setAlignment(Qt::AlignCenter);
     
        refBlackXXL = new QLabel(this);
        refBlackXXL->setGeometry(Init::FINAL_COL_2, Init::FINAL_LIN_6, Init::FINAL_WIDTH, Init::FINAL_HEIGHT);
        refBlackXXL->setFont(Init::FONT2);
        refBlackXXL->setAlignment(Qt::AlignCenter);
        refBlackXXL->setStyleSheet("QLabel { background-color : black; color : white}");
     
        refMagentaXXL = new QLabel(this);
        refMagentaXXL->setGeometry(Init::FINAL_COL_3, Init::FINAL_LIN_6, Init::FINAL_WIDTH, Init::FINAL_HEIGHT);
        refMagentaXXL->setFont(Init::FONT2);
        refMagentaXXL->setAlignment(Qt::AlignCenter);
        refMagentaXXL->setStyleSheet("QLabel { background-color : magenta}");
     
        refCyanXXL = new QLabel(this);
        refCyanXXL->setGeometry(Init::FINAL_COL_4, Init::FINAL_LIN_6, Init::FINAL_WIDTH, Init::FINAL_HEIGHT);
        refCyanXXL->setFont(Init::FONT2);
        refCyanXXL->setAlignment(Qt::AlignCenter);
        refCyanXXL->setStyleSheet("QLabel { background-color : cyan}");
     
        refYellowXXL = new QLabel(this);
        refYellowXXL->setGeometry(Init::FINAL_COL_5, Init::FINAL_LIN_6, Init::FINAL_WIDTH, Init::FINAL_HEIGHT);
        refYellowXXL->setFont(Init::FONT2);
        refYellowXXL->setAlignment(Qt::AlignCenter);
        refYellowXXL->setStyleSheet("QLabel { background-color : yellow}");
     
        XXLLabel = new QLabel(this);
        XXLLabel->setGeometry(Init::FINAL_COL_6, Init::FINAL_LIN_6, Init::FINAL_WIDTH, Init::FINAL_HEIGHT);
        XXLLabel->setFont(Init::FONT2);
        XXLLabel->setAlignment(Qt::AlignCenter);
     
        // 7th line labels
        nPageXXL = new QLabel(tr("Nombre pages*"), this);
        nPageXXL->setGeometry(Init::FINAL_COL_1, Init::FINAL_LIN_7, Init::FINAL_WIDTH, Init::FINAL_HEIGHT);
        nPageXXL->setFont(Init::FONT2);
        nPageXXL->setAlignment(Qt::AlignCenter);
     
        nPageBlackXXL = new QLabel(this);
        nPageBlackXXL->setGeometry(Init::FINAL_COL_2, Init::FINAL_LIN_7, Init::FINAL_WIDTH, Init::FINAL_HEIGHT);
        nPageBlackXXL->setFont(Init::FONT2);
        nPageBlackXXL->setAlignment(Qt::AlignCenter);
     
        nPageMagentaXXL = new QLabel(this);
        nPageMagentaXXL->setGeometry(Init::FINAL_COL_3, Init::FINAL_LIN_7, Init::FINAL_WIDTH, Init::FINAL_HEIGHT);
        nPageMagentaXXL->setFont(Init::FONT2);
        nPageMagentaXXL->setAlignment(Qt::AlignCenter);
     
        nPageCyanXXL = new QLabel(this);
        nPageCyanXXL->setGeometry(Init::FINAL_COL_4, Init::FINAL_LIN_7, Init::FINAL_WIDTH, Init::FINAL_HEIGHT);
        nPageCyanXXL->setFont(Init::FONT2);
        nPageCyanXXL->setAlignment(Qt::AlignCenter);
     
        nPageYellowXXL = new QLabel(this);
        nPageYellowXXL->setGeometry(Init::FINAL_COL_5, Init::FINAL_LIN_7, Init::FINAL_WIDTH, Init::FINAL_HEIGHT);
        nPageYellowXXL->setFont(Init::FONT2);
        nPageYellowXXL->setAlignment(Qt::AlignCenter);
     
        // 8th line labels
        infoLabel1 = new QLabel(tr("<i>* Données constructeur (nombre de pages A4)<br>Pour les cartouches photos le nombre de pages estimées est le nombre de photos 10x15</i>"), this);
        infoLabel1->setGeometry(Init::FINAL_COL_2, Init::FINAL_LIN_8, Init::FINAL_WIDTH * 5, Init::FINAL_HEIGHT * 2);
        infoLabel1->setFont(Init::FONT2);
     
        exitButton = new QPushButton(QIcon("pictures/back.png"), "", this);
        exitButton->setGeometry(Init::EXIT_X, Init::EXIT_Y, Init::EXIT_WIDTH, Init::EXIT_HEIGHT);
        exitButton->setIconSize(QSize(Init::EXIT_WIDTH, Init::EXIT_HEIGHT));
    }
     
    void FinalWindow::Slots()
    {
        connect(exitButton, SIGNAL(clicked()), this, SLOT(close()));
    }
     
    std::string FinalWindow::ReadInfos(std::ifstream &file)
    {
        std::string word;
        file >> word;
        return word;
    }
     
    void FinalWindow::SearchInfos(std::ifstream &file, std::string model)
    {
        std::string line;
        while(getline(file, line))
        {
            if(line == model)
            {
                AssignInfos(file);
            }
        }
    }
     
    void FinalWindow::AssignInfos(std::ifstream &file)
    {
        typeLabel->setText(QString::fromStdString(ReadInfos(file)));
     
        refBlack->setText(QString::fromStdString(ReadInfos(file)));
        refMagenta->setText(QString::fromStdString(ReadInfos(file)));
        refCyan->setText(QString::fromStdString(ReadInfos(file)));
        refYellow->setText(QString::fromStdString(ReadInfos(file)));
     
        refBlackXL->setText(QString::fromStdString(ReadInfos(file)));
        refMagentaXL->setText(QString::fromStdString(ReadInfos(file)));
        refCyanXL->setText(QString::fromStdString(ReadInfos(file)));
        refYellowXL->setText(QString::fromStdString(ReadInfos(file)));
     
        refBlackXXL->setText(QString::fromStdString(ReadInfos(file)));
        refMagentaXXL->setText(QString::fromStdString(ReadInfos(file)));
        refCyanXXL->setText(QString::fromStdString(ReadInfos(file)));
        refYellowXXL->setText(QString::fromStdString(ReadInfos(file)));
     
        nPageBlack->setText(QString::fromStdString(ReadInfos(file)));
        nPageMagenta->setText(QString::fromStdString(ReadInfos(file)));
        nPageCyan->setText(QString::fromStdString(ReadInfos(file)));
        nPageYellow->setText(QString::fromStdString(ReadInfos(file)));
     
        nPageBlackXL->setText(QString::fromStdString(ReadInfos(file)));
        nPageMagentaXL->setText(QString::fromStdString(ReadInfos(file)));
        nPageCyanXL->setText(QString::fromStdString(ReadInfos(file)));
        nPageYellowXL->setText(QString::fromStdString(ReadInfos(file)));
     
        nPageBlackXXL->setText(QString::fromStdString(ReadInfos(file)));
        nPageMagentaXXL->setText(QString::fromStdString(ReadInfos(file)));
        nPageCyanXXL->setText(QString::fromStdString(ReadInfos(file)));
        nPageYellowXXL->setText(QString::fromStdString(ReadInfos(file)));
     
        if (typeLabel->text().toStdString() == "Cartouche")
            XXLLabel->setText("PHOTO");
        else
            XXLLabel->setText("XXL");
    }

  3. #3
    Responsable 2D/3D/Jeux


    Avatar de LittleWhite
    Homme Profil pro
    Ingénieur développement logiciels
    Inscrit en
    Mai 2008
    Messages
    27 161
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Ingénieur développement logiciels

    Informations forums :
    Inscription : Mai 2008
    Messages : 27 161
    Billets dans le blog
    152
    Par défaut
    Bonjour,

    Quand j'exécute mon application elle utilise environ 440 Mo de mémoire vive à peine ouverte et à chaque fois que je clique sur un bouton (pour ouvrir la page suivante) cela me rajoute 5 Mo à chaque fois seulement au 1er lancement de chaque page (exemple, si j'ouvre 10 fois la page de la marque 1, je n'ai qu'une fois 5 Mo ajouté).
    Même si le constat est flagrant, ce n'est pas la bonne méthode (du moins, pas celle qui est scientifique et utile). La bonne méthode c'est d'utiliser un outil comme valgrind/Dr Memory pour avoir un vrai rapport sur l'utilisation mémoire. On lira donc ce tutoriel : http://alexandre-laurent.developpez....pplication/#L6

    En C++ (C++11 précisément), on a pas besoin de gérer la mémoire soi même. Plus précisément, on a pas besoin de faire de new/delete. Les pointeurs devraient tous être encapsulé dans des pointeurs intelligents (shared_ptd/unique_ptr).
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    void Button1Clicked();
        void Button2Clicked();
        void Button3Clicked();
        void Button4Clicked();
        void Button5Clicked();
        void Button6Clicked();
        void Button7Clicked();
        void Button8Clicked();
        void Button9Clicked();
        void Button10Clicked();
        void Button11Clicked();
        void Button12Clicked();
        void Button13Clicked();
        void Button14Clicked();
        void Button15Clicked();
        void Button16Clicked();
        void Button17Clicked();
        void Button18Clicked();
        void Button19Clicked();
        void Button20Clicked();
        void Button21Clicked();
        void Button22Clicked();
        void Button23Clicked();
        void Button24Clicked();
        void Button25Clicked();
        void Button26Clicked();
        void Button27Clicked();
        void Button28Clicked();
        void Button29Clicked();
        void Button30Clicked();
    Ne voulez vous pas faire un QSignalMapper :'(
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    Button4 = new QPushButton(this);
        Button4->setGeometry(Init::MODEL_COL_4, Init::MODEL_LIN_1, Init::MODEL_WIDTH, Init::MODEL_HEIGHT);
        Button4->setFont(Init::FONT2);
     
        Button5 = new QPushButton(this);
        Button5->setGeometry(Init::MODEL_COL_5, Init::MODEL_LIN_1, Init::MODEL_WIDTH, Init::MODEL_HEIGHT);
        Button5->setFont(Init::FONT2);
     
        Button6 = new QPushButton(this);
        Button6->setGeometry(Init::MODEL_COL_1, Init::MODEL_LIN_2, Init::MODEL_WIDTH, Init::MODEL_HEIGHT);
        Button6->setFont(Init::FONT2);
     
        Button7 = new QPushButton(this);
        Button7->setGeometry(Init::MODEL_COL_2, Init::MODEL_LIN_2, Init::MODEL_WIDTH, Init::MODEL_HEIGHT);
        Button7->setFont(Init::FONT2);
     
        Button8 = new QPushButton(this);
        Button8->setGeometry(Init::MODEL_COL_3, Init::MODEL_LIN_2, Init::MODEL_WIDTH, Init::MODEL_HEIGHT);
        Button8->setFont(Init::FONT2);
     
        Button9 = new QPushButton(this);
        Button9->setGeometry(Init::MODEL_COL_4, Init::MODEL_LIN_2, Init::MODEL_WIDTH, Init::MODEL_HEIGHT);
        Button9->setFont(Init::FONT2);
     
        Button10 = new QPushButton(this);
        Button10->setGeometry(Init::MODEL_COL_5, Init::MODEL_LIN_2, Init::MODEL_WIDTH, Init::MODEL_HEIGHT);
        Button10->setFont(Init::FONT2);
     
        Button11 = new QPushButton(this);
        Button11->setGeometry(Init::MODEL_COL_1, Init::MODEL_LIN_3, Init::MODEL_WIDTH, Init::MODEL_HEIGHT);
        Button11->setFont(Init::FONT2);
     
        Button12 = new QPushButton(this);
        Button12->setGeometry(Init::MODEL_COL_2, Init::MODEL_LIN_3, Init::MODEL_WIDTH, Init::MODEL_HEIGHT);
        Button12->setFont(Init::FONT2);
     
        Button13 = new QPushButton(this);
        Button13->setGeometry(Init::MODEL_COL_3, Init::MODEL_LIN_3, Init::MODEL_WIDTH, Init::MODEL_HEIGHT);
        Button13->setFont(Init::FONT2);
     
        Button14 = new QPushButton(this);
        Button14->setGeometry(Init::MODEL_COL_4, Init::MODEL_LIN_3, Init::MODEL_WIDTH, Init::MODEL_HEIGHT);
        Button14->setFont(Init::FONT2);
     
        Button15 = new QPushButton(this);
        Button15->setGeometry(Init::MODEL_COL_5, Init::MODEL_LIN_3, Init::MODEL_WIDTH, Init::MODEL_HEIGHT);
        Button15->setFont(Init::FONT2);
     
        Button16 = new QPushButton(this);
        Button16->setGeometry(Init::MODEL_COL_1, Init::MODEL_LIN_4, Init::MODEL_WIDTH, Init::MODEL_HEIGHT);
        Button16->setFont(Init::FONT2);
     
        Button17 = new QPushButton(this);
        Button17->setGeometry(Init::MODEL_COL_2, Init::MODEL_LIN_4, Init::MODEL_WIDTH, Init::MODEL_HEIGHT);
        Button17->setFont(Init::FONT2);
     
        Button18 = new QPushButton(this);
        Button18->setGeometry(Init::MODEL_COL_3, Init::MODEL_LIN_4, Init::MODEL_WIDTH, Init::MODEL_HEIGHT);
        Button18->setFont(Init::FONT2);
     
        Button19 = new QPushButton(this);
        Button19->setGeometry(Init::MODEL_COL_4, Init::MODEL_LIN_4, Init::MODEL_WIDTH, Init::MODEL_HEIGHT);
        Button19->setFont(Init::FONT2);
     
        Button20 = new QPushButton(this);
        Button20->setGeometry(Init::MODEL_COL_5, Init::MODEL_LIN_4, Init::MODEL_WIDTH, Init::MODEL_HEIGHT);
        Button20->setFont(Init::FONT2);
     
        Button21 = new QPushButton(this);
        Button21->setGeometry(Init::MODEL_COL_1, Init::MODEL_LIN_5, Init::MODEL_WIDTH, Init::MODEL_HEIGHT);
        Button21->setFont(Init::FONT2);
     
        Button22 = new QPushButton(this);
        Button22->setGeometry(Init::MODEL_COL_2, Init::MODEL_LIN_5, Init::MODEL_WIDTH, Init::MODEL_HEIGHT);
        Button22->setFont(Init::FONT2);
     
        Button23 = new QPushButton(this);
        Button23->setGeometry(Init::MODEL_COL_3, Init::MODEL_LIN_5, Init::MODEL_WIDTH, Init::MODEL_HEIGHT);
        Button23->setFont(Init::FONT2);
     
        Button24 = new QPushButton(this);
        Button24->setGeometry(Init::MODEL_COL_4, Init::MODEL_LIN_5, Init::MODEL_WIDTH, Init::MODEL_HEIGHT);
        Button24->setFont(Init::FONT2);
     
        Button25 = new QPushButton(this);
        Button25->setGeometry(Init::MODEL_COL_5, Init::MODEL_LIN_5, Init::MODEL_WIDTH, Init::MODEL_HEIGHT);
        Button25->setFont(Init::FONT2);
     
        Button26 = new QPushButton(this);
        Button26->setGeometry(Init::MODEL_COL_1, Init::MODEL_LIN_6, Init::MODEL_WIDTH, Init::MODEL_HEIGHT);
        Button26->setFont(Init::FONT2);
     
        Button27 = new QPushButton(this);
        Button27->setGeometry(Init::MODEL_COL_2, Init::MODEL_LIN_6, Init::MODEL_WIDTH, Init::MODEL_HEIGHT);
        Button27->setFont(Init::FONT2);
     
        Button28 = new QPushButton(this);
        Button28->setGeometry(Init::MODEL_COL_3, Init::MODEL_LIN_6, Init::MODEL_WIDTH, Init::MODEL_HEIGHT);
        Button28->setFont(Init::FONT2);
     
        Button29 = new QPushButton(this);
        Button29->setGeometry(Init::MODEL_COL_4, Init::MODEL_LIN_6, Init::MODEL_WIDTH, Init::MODEL_HEIGHT);
        Button29->setFont(Init::FONT2);
     
        Button30 = new QPushButton(this);
        Button30->setGeometry(Init::MODEL_COL_5, Init::MODEL_LIN_6, Init::MODEL_WIDTH, Init::MODEL_HEIGHT);
        Button30->setFont(Init::FONT2);
    Et un tableau, et une boucle for :'(

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    void FinalWindow::Button()
    {
    Des allocations dans cette fonction. Cela veut dire que vous demandez toujours plus de mémoire au système à chaque exécution de cette fonction. Vous ne pouvez pas réutiliser vos variables ?

    En C++11, le nouveau mot d'ordre c'est : on évite les pointeurs et les new.
    Vous souhaitez participer à la rubrique 2D/3D/Jeux ? Contactez-moi

    Ma page sur DVP
    Mon Portfolio

    Qui connaît l'erreur, connaît la solution.

  4. #4
    Membre averti
    Homme Profil pro
    Formateur en informatique
    Inscrit en
    Février 2015
    Messages
    59
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 46
    Localisation : France, Seine Maritime (Haute Normandie)

    Informations professionnelles :
    Activité : Formateur en informatique
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Février 2015
    Messages : 59
    Par défaut
    Tout d'abord, merci LittleWhite.

    Depuis mon post j'ai repris mon application depuis le début.

    Plutôt que de gérer environ 175 pages, maintenant je n'en ai plus qu'une seule.

    Sur cette page j'ai :

    - des boutons pour les choix des marques
    - des boutons pour le choix du type (encre / laser)
    - des boutons pour le choix des familles
    (depuis hier soir j'en suis là ;-) )

    et je vais ajouter :
    - des boutons pour le choix des modèles
    - des champs de texte (QLabel) pour afficher les références

    Bien entendu je joue sur les status hide() et show() pour n'afficher que ce dont j'ai besoin au moment voulu (en fonction du bouton cliqué), et chacun de ces boutons à sa propre fonction/SLOT.

    A cet instant je n'utilise plus qu'environ 50 Mo de ram qui peuvent s'alourdir de 5 à 10 Mo mais retombent après à environ 50 Mo.

    Je vais donc suivre tes conseils et supprimer les pointeurs et les "new" et je vais également mettre en place quelques boucle pour la création des boutons...

  5. #5
    Membre averti
    Homme Profil pro
    Formateur en informatique
    Inscrit en
    Février 2015
    Messages
    59
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 46
    Localisation : France, Seine Maritime (Haute Normandie)

    Informations professionnelles :
    Activité : Formateur en informatique
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Février 2015
    Messages : 59
    Par défaut
    A cet instant (enfin à hier soir), voici mon nouveau début de code (j'ai conservé mon fichier Init et sons header tel qu'à la première version, ne servant qu'à définir les polices et les positions)

    main.cpp (le même)
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    #include <QApplication>
     
    #include "MainWindow.h"
     
     
    int main(int argc, char *argv[])
    {
        QApplication app(argc, argv);
     
        MainWindow window;
        window.show();
     
        return app.exec();
    }
    MainWindow.h
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    #ifndef MAINWINDOW
    #define MAINWINDOW
     
    #include <QtWidgets>
    #include "Init.h"
     
    class MainWindow : public QWidget
    {
        Q_OBJECT
     
        public:
        MainWindow();
     
        private slots:
        void HomeWindow();
        void runBrother();
        void runCanon();
        void runEpson();
        void runHp();
        void runLexmark();
        void runSamsung();
        void InkClicked();
        void LaserClicked();
        void NextSeriesButtonClicked();
        void PreviousSeriesButtonClicked();
     
        private:
        int myPage;
        int seriesNumber;
        std::string myMark;
     
        std::string series1;
        std::string series2;
        std::string series3;
        std::string series4;
        std::string series5;
        std::string series6;
        std::string series7;
        std::string series8;
        std::string series9;
        std::string series10;
        std::string series11;
        std::string series12;
        std::string series13;
        std::string series14;
        std::string series15;
        std::string series16;
        std::string series17;
        std::string series18;
        std::string series19;
        std::string series20;
        std::string series21;
        std::string series22;
     
     
        QPushButton *brotherButton;
        QPushButton *canonButton;
        QPushButton *epsonButton;
        QPushButton *hpButton;
        QPushButton *lexmarkButton;
        QPushButton *samsungButton;
     
        QPushButton *inkButton;
        QPushButton *laserButton;
     
        QPushButton *series1Button;
        QPushButton *series2Button;
        QPushButton *series3Button;
        QPushButton *series4Button;
        QPushButton *series5Button;
        QPushButton *series6Button;
        QPushButton *series7Button;
        QPushButton *series8Button;
        QPushButton *series9Button;
        QPushButton *series10Button;
     
        QPushButton *markPic;
        QPushButton *logo;
        QPushButton *nextSeriesButton;
        QPushButton *previousSeriesButton;
        QPushButton *exitButton;
     
        void TypeWindow();
        void HideTypeButtons();
        void HideSeriesButtons();
        void ShowSeriesFirstPage();
        void SetSeriesInfos();
        void ShowSeriesButton();
     
        void BrotherInkWindow();
        void BrotherLaserWindow();
        void CanonInkWindow();
        void CanonLaserWindow();
        void EpsonInkWindow();
        void EpsonLaserWindow();
        void HPInkWindow();
        void HPLaserWindow();
        void LexmarkInkWindow();
        void LexmarkLaserWindow();
        void SamsungInkWindow();
        void SamsungLaserWindow();
     
        void Button();
        void Slots();
    };
     
    #endif // MAINWINDOW
    MainWindow.cpp
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
    230
    231
    232
    233
    234
    235
    236
    237
    238
    239
    240
    241
    242
    243
    244
    245
    246
    247
    248
    249
    250
    251
    252
    253
    254
    255
    256
    257
    258
    259
    260
    261
    262
    263
    264
    265
    266
    267
    268
    269
    270
    271
    272
    273
    274
    275
    276
    277
    278
    279
    280
    281
    282
    283
    284
    285
    286
    287
    288
    289
    290
    291
    292
    293
    294
    295
    296
    297
    298
    299
    300
    301
    302
    303
    304
    305
    306
    307
    308
    309
    310
    311
    312
    313
    314
    315
    316
    317
    318
    319
    320
    321
    322
    323
    324
    325
    326
    327
    328
    329
    330
    331
    332
    333
    334
    335
    336
    337
    338
    339
    340
    341
    342
    343
    344
    345
    346
    347
    348
    349
    350
    351
    352
    353
    354
    355
    356
    357
    358
    359
    360
    361
    362
    363
    364
    365
    366
    367
    368
    369
    370
    371
    372
    373
    374
    375
    376
    377
    378
    379
    380
    381
    382
    383
    384
    385
    386
    387
    388
    389
    390
    391
    392
    393
    394
    395
    396
    397
    398
    399
    400
    401
    402
    403
    404
    405
    406
    407
    408
    409
    410
    411
    412
    413
    414
    415
    416
    417
    418
    419
    420
    421
    422
    423
    424
    425
    426
    427
    428
    429
    430
    431
    432
    433
    434
    435
    436
    437
    438
    439
    440
    441
    442
    443
    444
    445
    446
    447
    448
    449
    450
    451
    452
    453
    454
    455
    456
    457
    458
    459
    460
    461
    462
    463
    464
    465
    466
    467
    468
    469
    470
    471
    472
    473
    474
    475
    476
    477
    478
    479
    480
    481
    482
    483
    484
    485
    486
    487
    488
    489
    490
    491
    492
    493
    494
    495
    496
    497
    498
    499
    500
    501
    502
    503
    504
    505
    506
    507
    508
    509
    510
    511
    512
    513
    514
    515
    516
    517
    518
    519
    520
    521
    522
    523
    524
    525
    526
    527
    528
    529
    530
    531
    532
    533
    534
    535
    536
    537
    538
    539
    540
    541
    542
    543
    544
    545
    546
    547
    548
    549
    550
    551
    552
    553
    554
    555
    556
    557
    558
    559
    560
    561
    562
    563
    564
    565
    566
    567
    568
    569
    570
    571
    572
    573
    574
    575
    576
    577
    578
    579
    580
    581
    582
    583
    584
    585
    586
    587
    588
    589
    590
    591
    592
    593
    594
    595
    596
    597
    598
    599
    600
    601
    602
    603
    604
    605
    606
    607
    608
    609
    610
    611
    612
    613
    614
    615
    616
    617
    618
    619
    620
    621
    622
    623
    624
    625
    626
    627
    628
    629
    630
    631
    632
    633
    634
    635
    636
    637
    638
    639
    640
    641
    642
    643
    644
    645
    646
    647
    648
    649
    650
    651
    652
    653
    654
    655
    656
    657
    658
    659
    660
    661
    662
    #include "MainWindow.h"
     
    MainWindow::MainWindow() : QWidget()
    {
        setMaximumSize(Init::WINDOW_WIDTH, Init::WINDOW_HEIGHT);
        setMinimumSize(Init::WINDOW_WIDTH, Init::WINDOW_HEIGHT);
        setWindowTitle(tr("Ink Finder"));
     
        Button();
     
        Slots();
    }
     
    //############### Private functions ###############
    void MainWindow::Button()
    {
        //###########################################################
        //############## Mark chooser window's buttons ##############
        //###########################################################
     
        brotherButton = new QPushButton(QIcon("pictures/brother.png"), "", this);
        brotherButton->setGeometry(Init::MARK_COL_1, Init::MARK_LIN_1, Init::MARK_WIDTH, Init::MARK_HEIGHT);
        brotherButton->setIconSize(QSize(Init::MARK_WIDTH, Init::MARK_HEIGHT));
        brotherButton->setFlat(true);
     
        canonButton = new QPushButton(QIcon("pictures/canon.png"), "", this);
        canonButton->setGeometry(Init::MARK_COL_2, Init::MARK_LIN_1, Init::MARK_WIDTH, Init::MARK_HEIGHT);
        canonButton->setIconSize(QSize(Init::MARK_WIDTH, Init::MARK_HEIGHT));
        canonButton->setFlat(true);
     
        epsonButton = new QPushButton(QIcon("pictures/epson.png"), "", this);
        epsonButton->setGeometry(Init::MARK_COL_1, Init::MARK_LIN_2, Init::MARK_WIDTH, Init::MARK_HEIGHT);
        epsonButton->setIconSize(QSize(Init::MARK_WIDTH, Init::MARK_HEIGHT));
        epsonButton->setFlat(true);
     
        hpButton = new QPushButton(QIcon("pictures/hp.png"), "", this);
        hpButton->setGeometry(Init::MARK_COL_2, Init::MARK_LIN_2, Init::MARK_WIDTH, Init::MARK_HEIGHT);
        hpButton->setIconSize(QSize(Init::MARK_WIDTH, Init::MARK_HEIGHT));
        hpButton->setFlat(true);
     
        lexmarkButton = new QPushButton(QIcon("pictures/lexmark.png"), "", this);
        lexmarkButton->setGeometry(Init::MARK_COL_1, Init::MARK_LIN_3, Init::MARK_WIDTH, Init::MARK_HEIGHT);
        lexmarkButton->setIconSize(QSize(Init::MARK_WIDTH, Init::MARK_HEIGHT));
        lexmarkButton->setFlat(true);
     
        samsungButton = new QPushButton(QIcon("pictures/samsung.png"), "", this);
        samsungButton->setGeometry(Init::MARK_COL_2, Init::MARK_LIN_3, Init::MARK_WIDTH, Init::MARK_HEIGHT);
        samsungButton->setIconSize(QSize(Init::MARK_WIDTH, Init::MARK_HEIGHT));
        samsungButton->setFlat(true);
     
        //###########################################################
        //############## Type chooser window's buttons ##############
        //###########################################################
     
        inkButton = new QPushButton("Jet d'encre", this);
        inkButton->setGeometry(Init::TYPE_COL_1, Init::TYPE_LIN_1, Init::TYPE_WIDTH, Init::TYPE_HEIGHT);
        inkButton->setFont(Init::FONT1);
        inkButton->hide();
     
        laserButton = new QPushButton("Laser", this);
        laserButton->setGeometry(Init::TYPE_COL_1, Init::TYPE_LIN_2, Init::TYPE_WIDTH, Init::TYPE_HEIGHT);
        laserButton->setFont(Init::FONT1);
        laserButton->hide();
     
        //###########################################################
        //############# Series chooser window's buttons #############
        //###########################################################
     
        series1Button = new QPushButton(this);
        series1Button->setGeometry(Init::HOME_COL_1, Init::HOME_LIN_1, Init::HOME_WIDTH, Init::HOME_HEIGHT);
        series1Button->setFont(Init::FONT6);
        series1Button->hide();
     
        series2Button = new QPushButton(this);
        series2Button->setGeometry(Init::HOME_COL_2, Init::HOME_LIN_1, Init::HOME_WIDTH, Init::HOME_HEIGHT);
        series2Button->setFont(Init::FONT6);
        series2Button->hide();
     
        series3Button = new QPushButton(this);
        series3Button->setGeometry(Init::HOME_COL_1, Init::HOME_LIN_2, Init::HOME_WIDTH, Init::HOME_HEIGHT);
        series3Button->setFont(Init::FONT6);
        series3Button->hide();
     
        series4Button = new QPushButton(this);
        series4Button->setGeometry(Init::HOME_COL_2, Init::HOME_LIN_2, Init::HOME_WIDTH, Init::HOME_HEIGHT);
        series4Button->setFont(Init::FONT6);
        series4Button->hide();
     
        series5Button = new QPushButton(this);
        series5Button->setGeometry(Init::HOME_COL_1, Init::HOME_LIN_3, Init::HOME_WIDTH, Init::HOME_HEIGHT);
        series5Button->setFont(Init::FONT6);
        series5Button->hide();
     
        series6Button = new QPushButton(this);
        series6Button->setGeometry(Init::HOME_COL_2, Init::HOME_LIN_3, Init::HOME_WIDTH, Init::HOME_HEIGHT);
        series6Button->setFont(Init::FONT6);
        series6Button->hide();
     
        series7Button = new QPushButton(this);
        series7Button->setGeometry(Init::HOME_COL_1, Init::HOME_LIN_4, Init::HOME_WIDTH, Init::HOME_HEIGHT);
        series7Button->setFont(Init::FONT6);
        series7Button->hide();
     
        series8Button = new QPushButton(this);
        series8Button->setGeometry(Init::HOME_COL_2, Init::HOME_LIN_4, Init::HOME_WIDTH, Init::HOME_HEIGHT);
        series8Button->setFont(Init::FONT6);
        series8Button->hide();
     
        series9Button = new QPushButton(this);
        series9Button->setGeometry(Init::HOME_COL_1, Init::HOME_LIN_5, Init::HOME_WIDTH, Init::HOME_HEIGHT);
        series9Button->setFont(Init::FONT6);
        series9Button->hide();
     
        series10Button = new QPushButton(this);
        series10Button->setGeometry(Init::HOME_COL_2, Init::HOME_LIN_5, Init::HOME_WIDTH, Init::HOME_HEIGHT);
        series10Button->setFont(Init::FONT6);
        series10Button->hide();
     
        //###########################################################
        //################# Common window's buttons #################
        //###########################################################
     
        logo = new QPushButton(QIcon("pictures/logo.png"), "", this);
        logo->setIconSize(QSize(Init::LOGO_WIDTH, Init::LOGO_HEIGHT));
        logo->setGeometry(Init::LOGO_X, Init::LOGO_Y, Init::LOGO_WIDTH, Init::LOGO_HEIGHT);
        logo->setFlat(true);
     
        markPic = new QPushButton(this);
        markPic->setIconSize(QSize(Init::MARK_WIDTH, Init::MARK_HEIGHT));
        markPic->setGeometry(Init::MARK_CENTER_X, Init::MARK_CENTER_Y, Init::MARK_WIDTH, Init::MARK_HEIGHT);
        markPic->setFlat(true);
        markPic->hide();
     
        nextSeriesButton = new QPushButton(QIcon("pictures/next.png"), "", this);
        nextSeriesButton->setGeometry(Init::EXIT_X - 75, Init::EXIT_Y, Init::EXIT_WIDTH, Init::EXIT_HEIGHT);
        nextSeriesButton->setIconSize(QSize(Init::EXIT_WIDTH, Init::EXIT_HEIGHT));
        nextSeriesButton->setFlat(true);
        nextSeriesButton->hide();
     
        previousSeriesButton = new QPushButton(QIcon("pictures/previous.png"), "", this);
        previousSeriesButton->setGeometry(Init::EXIT_X - 150, Init::EXIT_Y, Init::EXIT_WIDTH, Init::EXIT_HEIGHT);
        previousSeriesButton->setIconSize(QSize(Init::EXIT_WIDTH, Init::EXIT_HEIGHT));
        previousSeriesButton->setFlat(true);
        previousSeriesButton->hide();
     
        exitButton = new QPushButton(QIcon("pictures/back.png"), "", this);
        exitButton->setGeometry(Init::EXIT_X, Init::EXIT_Y, Init::EXIT_WIDTH, Init::EXIT_HEIGHT);
        exitButton->setIconSize(QSize(Init::EXIT_WIDTH, Init::EXIT_HEIGHT));
        exitButton->hide();
    }
     
    void MainWindow::Slots()
    {
        connect(brotherButton, SIGNAL(clicked(bool)), this, SLOT(runBrother()));
        connect(canonButton, SIGNAL(clicked(bool)), this, SLOT(runCanon()));
        connect(epsonButton, SIGNAL(clicked(bool)), this, SLOT(runEpson()));
        connect(hpButton, SIGNAL(clicked(bool)), this, SLOT(runHp()));
        connect(lexmarkButton, SIGNAL(clicked(bool)), this, SLOT(runLexmark()));
        connect(samsungButton, SIGNAL(clicked(bool)), this, SLOT(runSamsung()));
        connect(exitButton, SIGNAL(clicked(bool)), this, SLOT(HomeWindow()));
        connect(nextSeriesButton, SIGNAL(clicked(bool)), this, SLOT(NextSeriesButtonClicked()));
        connect(previousSeriesButton, SIGNAL(clicked(bool)), this, SLOT(PreviousSeriesButtonClicked()));
        connect(inkButton, SIGNAL(clicked(bool)), this, SLOT(InkClicked()));
        connect(laserButton, SIGNAL(clicked(bool)), this, SLOT(LaserClicked()));
    }
     
    void MainWindow::TypeWindow()
    {
        markPic->setIcon(QIcon(QString::fromStdString("pictures/" + myMark + ".png")));
        markPic->show();
     
        brotherButton->hide();
        canonButton->hide();
        epsonButton->hide();
        hpButton->hide();
        lexmarkButton->hide();
        samsungButton->hide();
     
        inkButton->show();
        laserButton->show();
     
        exitButton->show();
    }
     
    void MainWindow::HideTypeButtons()
    {
        inkButton->hide();
        laserButton->hide();
    }
     
    void MainWindow::HideSeriesButtons()
    {
        series1Button->hide();
        series2Button->hide();
        series3Button->hide();
        series4Button->hide();
        series5Button->hide();
        series6Button->hide();
        series7Button->hide();
        series8Button->hide();
        series9Button->hide();
        series10Button->hide();
    }
     
    void MainWindow::ShowSeriesFirstPage()
    {
        series1Button->show();
        series2Button->show();
        series3Button->show();
        series4Button->show();
        series5Button->show();
        series6Button->show();
        series7Button->show();
        series8Button->show();
        series9Button->show();
        series10Button->show();
    }
     
    void MainWindow::ShowSeriesButton()
    {
        HideSeriesButtons();
     
        int n = seriesNumber - (10 * (myPage - 1));
        int pageNumber = seriesNumber / 10;
        if ((seriesNumber % 10) != 0)
            pageNumber++;
     
        if (n >= 1)
            series1Button->show();
        if (n >= 2)
            series2Button->show();
        if (n >= 3)
            series3Button->show();
        if (n >= 4)
            series4Button->show();
        if (n >= 5)
            series5Button->show();
        if (n >= 6)
            series6Button->show();
        if (n >= 7)
            series7Button->show();
        if (n >= 8)
            series8Button->show();
        if (n >= 9)
            series9Button->show();
        if (n >= 10)
            series10Button->show();
     
        if (myPage == 1)
        {
            if (pageNumber > 1)
                nextSeriesButton->show();
            else
                nextSeriesButton->hide();
     
            previousSeriesButton->hide();
        }
        if (myPage == pageNumber && pageNumber > 1)
        {
            nextSeriesButton->hide();
            previousSeriesButton->show();
        }
        if (myPage > 1 && myPage < pageNumber)
        {
            nextSeriesButton->show();
            previousSeriesButton->show();
        }
    }
     
    void MainWindow::SetSeriesInfos()
    {
        if (myPage == 1)
        {
            series1Button->setText(QString::fromStdString(series1));
            series2Button->setText(QString::fromStdString(series2));
            series3Button->setText(QString::fromStdString(series3));
            series4Button->setText(QString::fromStdString(series4));
            series5Button->setText(QString::fromStdString(series5));
            series6Button->setText(QString::fromStdString(series6));
            series7Button->setText(QString::fromStdString(series7));
            series8Button->setText(QString::fromStdString(series8));
            series9Button->setText(QString::fromStdString(series9));
            series10Button->setText(QString::fromStdString(series10));
        }
        else if (myPage == 2)
        {
            series1Button->setText(QString::fromStdString(series11));
            series2Button->setText(QString::fromStdString(series12));
            series3Button->setText(QString::fromStdString(series13));
            series4Button->setText(QString::fromStdString(series14));
            series5Button->setText(QString::fromStdString(series15));
            series6Button->setText(QString::fromStdString(series16));
            series7Button->setText(QString::fromStdString(series17));
            series8Button->setText(QString::fromStdString(series18));
            series9Button->setText(QString::fromStdString(series19));
            series10Button->setText(QString::fromStdString(series20));
        }
        ShowSeriesButton();
    }
     
    void MainWindow::BrotherInkWindow()
    {    
        HideTypeButtons();
     
        seriesNumber = 3;
     
        series1 = "DCP";
        series2 = "FAX";
        series3 = "MFC";
     
        SetSeriesInfos();
    }
     
    void MainWindow::BrotherLaserWindow()
    {
        HideTypeButtons();
     
        seriesNumber = 6;
     
        series1 = "DCP";
        series2 = "FAX";
        series3 = "HL";
        series4 = "IntelliFax";
        series5 = "MFC";
        series6 = "WL";
     
        SetSeriesInfos();
    }
     
    void MainWindow::CanonInkWindow()
    {
        HideTypeButtons();
     
        seriesNumber = 17;
     
        series1 = "BJ";
        series2 = "BJC";
        series3 = "BN";
        series4 = "CP";
        series5 = "DS";
        series6 = "I";
        series7 = "JX";
        series8 = "MAXIFY";
        series9 = "MG";
        series10 = "MP";
        series11 = "MultiPass";
        series12 = "MX";
        series13 = "PIXMA";
        series14 = "S";
        series15 = "SELPHY";
        series16 = "SMARTBASE";
        series17 = "StarWriter";
     
        SetSeriesInfos();
    }
     
    void MainWindow::CanonLaserWindow()
    {
        HideTypeButtons();
     
        seriesNumber = 20;
     
        series1 = "CP";
        series2 = "FAX";
        series3 = "FC";
        series4 = "GP";
        series5 = "i-SENSYS";
        series6 = "ImageClass";
        series7 = "IR";
        series8 = "IR ADVANCE";
        series9 = "IRC";
        series10 = "Laser L";
        series11 = "LaserClass";
        series12 = "LBP";
        series13 = "MARK";
        series14 = "MF";
        series15 = "MP";
        series16 = "MultiPass";
        series17 = "NP";
        series18 = "PC";
        series19 = "PCD";
        series20 = "PowerFax";
     
        SetSeriesInfos();
    }
     
    void MainWindow::EpsonInkWindow()
    {
        HideTypeButtons();
     
        seriesNumber = 4;
     
        series1 = "Expression";
        series2 = "PictureMate";
        series3 = "Stylus";
        series4 = "WorkForce";
     
        SetSeriesInfos();
    }
     
    void MainWindow::EpsonLaserWindow()
    {
        HideTypeButtons();
     
        seriesNumber = 7;
     
        series1 = "ActionLaser";
        series2 = "AcuLaser";
        series3 = "EPL";
        series4 = "GQ";
        series5 = "LP";
        series6 = "M et MX";
        series7 = "WorkForce";
     
        SetSeriesInfos();
    }
     
    void MainWindow::HPInkWindow()
    {
        HideTypeButtons();
     
        seriesNumber = 22;
     
        series1 = "Apollo";
        series2 = "Business InkJet";
        series3 = "Color Copier";
        series4 = "Color InkJet";
        series5 = "Color Printer";
        series6 = "CopyJet";
        series7 = "CP";
        series8 = "DesignJet";
        series9 = "DeskJet";
        series10 = "DeskWriter";
        series11 = "Digital Copier";
        series12 = "Envy";
        series13 = "Fax";
        series14 = "OfficeJet";
        series15 = "OfficeJet Enterprise";
        series16 = "OfficeJet Pro";
        series17 = "Photosmart";
        series18 = "Photosmart Pro";
        series19 = "Professionnal";
        series20 = "PSC";
        series21 = "QuietJet";
        series22 = "ThinkJet";
     
        SetSeriesInfos();
    }
     
    void MainWindow::HPLaserWindow()
    {
        HideTypeButtons();
     
        seriesNumber = 6;
     
        series1 = "CM";
        series2 = "Color LaserJet";
        series3 = "LaserJet";
        series4 = "LaserJet Enterprise";
        series5 = "LaserJet Pro";
        series6 = "Mopier";
     
        SetSeriesInfos();
    }
     
    void MainWindow::LexmarkInkWindow()
    {
        HideTypeButtons();
     
        seriesNumber = 19;
     
        series1 = "Color Jet Printer";
        series2 = "Genesis";
        series3 = "Impact";
        series4 = "Interact";
        series5 = "Interpret";
        series6 = "Intuition";
        series7 = "Jet Printer I";
        series8 = "Jet Printer P";
        series9 = "Jet Printer X";
        series10 = "Jet Printer Z";
        series11 = "OfficeEdge";
        series12 = "Optra Color";
        series13 = "Pinnacle";
        series14 = "Platinum";
        series15 = "Prestige";
        series16 = "Prevail";
        series17 = "Pro";
        series18 = "Prospect";
        series19 = "S";
     
        SetSeriesInfos();
    }
     
    void MainWindow::LexmarkLaserWindow()
    {
        HideTypeButtons();
     
        seriesNumber = 19;
     
        series1 = "CS";
        series2 = "MS";
        series3 = "MX";
        series4 = "Optra-C";
        series5 = "Optra-Color";
        series6 = "Optra-E";
        series7 = "Optra-Image";
        series8 = "Optra-K";
        series9 = "Optra-L";
        series10 = "Optra-M";
        series11 = "Optra-R";
        series12 = "Optra-S";
        series13 = "Optra-SC";
        series14 = "Optra-SE";
        series15 = "Optra-T";
        series16 = "Optra-W";
        series17 = "Optra-X";
        series18 = "Pennant Systems IBM";
        series19 = "3000";
     
        SetSeriesInfos();
    }
     
    void MainWindow::SamsungInkWindow()
    {
        HideTypeButtons();
     
        seriesNumber = 8;
     
        series1 = "CJX";
        series2 = "FX";
        series3 = "Msys";
        series4 = "MultiJet";
        series5 = "MyJet";
        series6 = "SCX";
        series7 = "SF";
        series8 = "SmartJet";
     
        SetSeriesInfos();
    }
     
    void MainWindow::SamsungLaserWindow()
    {
        HideTypeButtons();
     
        seriesNumber = 11;
     
        series1 = "CLP";
        series2 = "CLX";
        series3 = "IZZI";
        series4 = "ML";
        series5 = "MSYS";
        series6 = "MultiXpress";
        series7 = "ProXpress";
        series8 = "QWICKLASER";
        series9 = "SCX";
        series10 = "SF";
        series11 = "SL";
     
        SetSeriesInfos();
    }
     
    //############### Private slots ###############
    void MainWindow::HomeWindow()
    {
        HideTypeButtons();
        HideSeriesButtons();
     
        markPic->hide();
        exitButton->hide();
        nextSeriesButton->hide();
        previousSeriesButton->hide();
     
        brotherButton->show();
        canonButton->show();
        epsonButton->show();
        hpButton->show();
        lexmarkButton->show();
        samsungButton->show();
    }
     
    void MainWindow::runBrother()
    {
        myMark = "brother";
        TypeWindow();
    }
     
    void MainWindow::runCanon()
    {
        myMark = "canon";
        TypeWindow();
    }
     
    void MainWindow::runEpson()
    {
        myMark = "epson";
        TypeWindow();
    }
     
    void MainWindow::runHp()
    {
        myMark = "hp";
        TypeWindow();
    }
     
    void MainWindow::runLexmark()
    {
        myMark = "lexmark";
        TypeWindow();
    }
     
    void MainWindow::runSamsung()
    {
        myMark = "samsung";
        TypeWindow();
    }
     
    void MainWindow::InkClicked()
    {
        myPage = 1;
        if (myMark == "brother")
            BrotherInkWindow();
        else if (myMark == "canon")
            CanonInkWindow();
        else if (myMark == "epson")
            EpsonInkWindow();
        else if (myMark == "hp")
            HPInkWindow();
        else if (myMark == "lexmark")
            LexmarkInkWindow();
        else if (myMark == "samsung")
            SamsungInkWindow();
    }
     
    void MainWindow::LaserClicked()
    {
        myPage = 1;
        if (myMark == "brother")
            BrotherLaserWindow();
        else if (myMark == "canon")
            CanonLaserWindow();
        else if (myMark == "epson")
            EpsonLaserWindow();
        else if (myMark == "hp")
            HPLaserWindow();
        else if (myMark == "lexmark")
            LexmarkLaserWindow();
        else if (myMark == "samsung")
            SamsungLaserWindow();
    }
     
    void MainWindow::NextSeriesButtonClicked()
    {
        myPage++;
        SetSeriesInfos();
    }
     
    void MainWindow::PreviousSeriesButtonClicked()
    {
        myPage--;
        SetSeriesInfos();
    }
    A cet instant, le passage sur l'assignation des valeurs aux boutons est assez lourd. Je vais le remplacer par un fichier .txt (comme pour ma base de données) contenant les valeurs des boutons et j'ajouterai une (ou des) boucle(s) pour assigner les valeurs aux boutons à partir du .txt

  6. #6
    Responsable 2D/3D/Jeux


    Avatar de LittleWhite
    Homme Profil pro
    Ingénieur développement logiciels
    Inscrit en
    Mai 2008
    Messages
    27 161
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Ingénieur développement logiciels

    Informations forums :
    Inscription : Mai 2008
    Messages : 27 161
    Billets dans le blog
    152
    Par défaut
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    std::string series1;
    std::string series2;
    std::string series3;
    std::string series4;
    std::string series5;
    std::string series6;
    std::string series7;
    std::string series8;
    std::string series9;
    std::string series10;
    std::string series11;
    std::string series12;
    std::string series13;
    std::string series14;
    std::string series15;
    std::string series16;
    std::string series17;
    std::string series18;
    std::string series19;
    std::string series20;
    std::string series21;
    std::string series22;
    Tableauuuuu !!!!!
    Vous souhaitez participer à la rubrique 2D/3D/Jeux ? Contactez-moi

    Ma page sur DVP
    Mon Portfolio

    Qui connaît l'erreur, connaît la solution.

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. fuite de mémoire ?
    Par salseropom dans le forum C
    Réponses: 2
    Dernier message: 12/01/2006, 16h19
  2. Réponses: 1
    Dernier message: 02/12/2005, 14h18
  3. fuite de mémoire
    Par mamag dans le forum MFC
    Réponses: 17
    Dernier message: 19/08/2005, 10h42
  4. Fuite de mémoire en utilisant le template list
    Par schtroumpf_farceur dans le forum Langage
    Réponses: 9
    Dernier message: 18/07/2005, 20h44
  5. Réponses: 8
    Dernier message: 17/10/2002, 12h52

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo