Important: Please read the Qt Code of Conduct -

Unable to align Formlayout

  • Hi All,I have a top Horizontal Layout, to which I have added Formlayout.The form layout gets aligned to the top by default.I tried to change its alignment ,but its not changing.Below is my code:

     QHBoxLayout *hParentLayout = new QHBoxLayout();
     QFormLayout *formLayout = new QFormLayout();
    //Create Label
    QLabel* label=new QLabel();
    QStringList list;
    QComboBox *comboBox = new QComboBox;
    formLayout->setAlignment(Qt::AlignBottom);//This is not changing
    formLayout->addRow(label, comboBox);

    Any input will be really useful.

  • Lifetime Qt Champion

    @Adit Maybe it's alignment in the QHBoxLayout?

  • Thank you man,its working.But I have a question.Actually I had another child horizontal layout along with child form layout.But this child horizontal layout is center aligned by default and using childHorizontalLayout.setAlignment(..) call actually works.Then why this call didn't work for the Form Layout ?Any idea?

Log in to reply