Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QVBoxLayout not shown corectly
Qt 6.11 is out! See what's new in the release blog

QVBoxLayout not shown corectly

Scheduled Pinned Locked Moved General and Desktop
2 Posts 2 Posters 1.4k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Z Offline
    Z Offline
    zolidznake
    wrote on last edited by
    #1

    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++){
    
    layout->addWidget(fblist.at(i));
    
    
    
    }
    

    http://postimage.org/image/vy0vs2rip/

    thank you,

    1 Reply Last reply
    0
    • B Offline
      B Offline
      broadpeak
      wrote on last edited by
      #2

      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)
      layout->addStretch();

      widget.setLayout( layout ); // important
      @

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved