0

in my project, I have a QScrollArea in a QTabWidget , in this QTabWidget i had few IHM. I would like to put two IHM per line, and when you arrive at the end of QTabWidget , the scrollbar scroll .

This is my class diagram :

Class diagram CU2

My code in MainWindow where i created the QScrollBar :

     //Here I create the QScrollArea
     QScrollArea *scrollArea = new QScrollArea();
     scrollArea->setWidgetResizable(true);
     scrollArea->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn);

     //I had the QScrollBar in the Tab of my QTabWidget
     ui->tabWidget->addTab(scrollArea,"Plateau " + ControleSpecial.at(i).toElement().attribute("ID"));

     //I call my class Plateau (i'm french ^^)
     Plateau *plt = new Plateau(ui->tabWidget);
     plt->Rajouter(ControleSpecial.at(i),scrollArea,ui->InfoPlt,column,row);
     this->nPlateau.append(plt);

My class Analyse , where i had this IHM : IHM analyse

the code :

        {
                //I create the layout and ScrollWidget
                QGridLayout *layout = new QGridLayout;
                QWidget *scrollwidget = new QWidget;

                int row = 0;
                int column = 0;

                QDomNode Analyse;

                for(int i=1;i<plateau.childNodes().count()+1;++i)
                {

                    Analyse = plateau.childNodes().at(i-1);

                    QString nomAnalyse = Analyse.toElement().attribute("Type");
                    vTypeAnalyse.append(nomAnalyse);


                    if(nomAnalyse == "Traction_Perpendiculaire")
                    {
                        Traction_Perpendiculaire* TP = new Traction_Perpendiculaire();
                        QGroupBox* analyse = TP->recuperationAnalyse();

                        //I add the analyse IHM in the layout
                        layout->addWidget(TP,row,column);

                        //I don't think my problem it's here
                        vButtonAnalyse.append(TP->recuperationButton());
                        connect(vButtonAnalyse[vButtonAnalyse.size()-1],SIGNAL(clicked()),this,SLOT(Recuperation()));
                        vButtonAnalyse[vButtonAnalyse.size()-1]->setAccessibleName(QString::number(i-1));

                        Eprouvette *blocEprouvette = new Eprouvette(analyse);
                        this->vbloceprouvette.append(blocEprouvette);
                        blocEprouvette->Rajouter(Analyse);
                    }

                    if(i%2 == 0)
                    {
                        column = 0;
                        row += 1;
                    }
                    else
                    {
                        column += 1;
                    }
                }

                //And I had the layout in scrollWidget and ScrollWidget in scrollArea
                scrollwidget->setLayout(layout);
                scrollArea->setWidget(scrollwidget);
                //tab->widget(index)
            }

And i obtain that:

enter image description here

So if you have any ideas , any ideas would be well come. Thank you in advance. (sorry for my bad english)

JasonMArcher
  • 14,195
  • 22
  • 56
  • 52

1 Answers1

0

Ok so , when i had the HMI in the layout it's don't work but when i had the QGroupBox it's work. So i resolve it like this :

layout->addWidget(TP,row,column);

//to :

layout->addWidget(TP->MyGroupBox(),row,column);