I tried very hard. But, still am not satisfied with the implementation. And now am feeling helpless.
If I set set, fixedsize for QLabel, then scroll bars won't appear if I use zoomout/zoomin.
My question is why QLabel won't shrink back after changing size through Qsplitter. I tried all the combinations of sizepolicy and nothing has worked so far
The focus changed when you clicked the button. What you can do is to keep track on the currently focused QLineEdit in a member variable so you can use it at deletion time. Or you could add a remove button besides your QLineEdit and use that to remove them.
I have used a scroll area for something similar. I setup mine a little different. I use widgets to contain each child item (not layouts)
// constructor of parent widget
scroll_area = new QScrollArea(this);
d_scroll_area_widget = new QWidget();
d_scroll_area_layout = new QVBoxLayout(d_scroll_area_widget);
// see note below for explanation of spacer
d_bottom_vertical_spacer = new QSpacerItem(100, 20, QSizePolicy::Minimum, QSizePolicy::Expanding);
The bottom spacer is to make sure that if there is only one child widget of the scroll area it is not resized to fill all the available space. The bottom spacer is always moved to the bottom.
Removing items is a bit more tougher. Actually, in my implementation, I don't. I hide the ones I want to remove and re-assign them if they are re-used in the future. In my case it works for what I need it to do but it may not be practical if you have something where you want to insert / delete / move items.
As @SGaist mentioned you can use a QListView/QListWidget. The items do not need to be the same size and they can be resized after the fact if more or less information is displayed which changes the size.
d_ReportListView = new TListView; // subclass of QListWidget
// important function to enable resizing QListWidgetItems
// if a list widget item size is changed update the size hits of that item
LineHeight = TListViewItem::LineHeight(); // fixed line height
ItemSize = this->size(); // size of parent
ItemSize.setHeight(num_lines * LineHeight); // only adjusting height to fit required lines
// LVItem = pointer to current QListWidgetItem that need to be set or changed