Qt World Summit: Submit your Presentation

QFormlayout with three options on the same line

  • For my program I inserted a Qformlayout but I would like the three options () to be on the same line. Like this
    Votre Classe : listedesclasses Série: listedesclasses, N°: listedesclasses
    How can I do ?
    Here's the code

     QFormLayout *cridebase = new QFormLayout;
        cridebase->addRow("Votre Matière", listedesmatiere);
        cridebase->addRow("Son Coeficient", coeficient);
        cridebase->addRow("Classe", listedesclasses); //1
        cridebase->addRow("Série", listedesseries); // 2
        cridebase->addRow("N° Classe", numerodeclasse); // 3    (1 + 2 + 3 on same line)
        QGridLayout *critdbase = new QGridLayout; //Un grille layout pour disposer correctement les différent élements de la fenêtre
        critdbase->addWidget(bienvenue, 1, 0, 6, 6);  //(bouton3, 1, 0, 1, 2);
        critdbase->addLayout(cridebase, 7, 0, 6, 6);
        critdbase->addWidget(bttcreer, 8, 3);
        critdbase->addWidget(bttannuler, 8, 5);

    I left the QGridlayout because I looked for the solution with him but it did not work.
    I am beginner so be explicit.
    Thank you in advance...

  • @Nafab213

    Im not 100% sure, but I think you can use only 2 widgets (i.e. one for a label and one for a LineEdit) per line in a formlayout?!

    You can use a GridLayout in this case or you combine multiple Horizontal- and Vertical-Layouts

  • Lifetime Qt Champion

    @Nafab213 Put these 3 widgets as children on a parent widget and put this parent widget to the form layout.

Log in to reply