I am trying to add QLabels to a QverticalLayout in Pyside2, which should update with the text of certain file names. I want to have dynamic widget creation i.e the widgets should get added as the number of file name increases.
I am having no idea how to implement the same. The widgets are also not shown in the Layout.

Qt Code:
  1. label=QtWidgets.QLabel()
  2. #label.setStyleSheet("QLabel { background-color : green; color : black; }"); // I tried the commented part of the code for the labels but no luck
  3. #label = self.ui.verticalLayout.itemAt(index).widget()
  4. label.setStyleSheet("QLabel { background-color : white; color : black; }");
  5. label.setText=localFile
  6. self.ui.verticalLayout.addWidget(label)
  7. index=index+1
To copy to clipboard, switch view to plain text mode 

I am unable to get the label in the designated place.