QVBoxLayout not shown corectly

  • Hi,

    I want to create a list of widgets and put the elements in a QVBoxLayout using this code:

    fblist is a QList of widget

    QVBoxLayout *layout = new QVBoxLayout;

    for(int i = 0; i < fblist.size(); i++){


    thank you,

  • Try something like this:
    QWidget widget;

    QLineEdit* lineEdit = new QLineEdit;
    QLabel* label = new QLabel;

    QVBoxLayout* layout = new QVBoxLayout;
    //replace these with your for loop
    layout->addWidget( lineEdit );
    layout->addWidget( label );

    // you can use this at the end of the widgets (after the for loop)

    widget.setLayout( layout ); // important

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.