Hello,

Please I will need you help. I am not that proficient with QTableWidget and honestly need your help with proper guidance.
Before I came here, I have made several research but to no avail. I have also studied the Qt documentation but don't understand it.

I have basic knowledge of Python and pyqt5 and have written some projects anyway, my problem is with QTableWidget.

I am writing a program and in one of the windows, a click of a button loads a window with a qtablewidget in it. This qtablewidget displays retrieved records from the database.
Please I need a line of code that can make any selected row of the qTablewidget to be displayed in a particular lineEdit in the same class with the qTableWidget.
I would prefer a code example as an illustration. Please. In the attached photo, you can see the selectedRow label and its QLineEdit which is readOnly, please I want the content of the selectedRow in the qtablewidget to display in that QLineEdit.

Kindly help me with code based on my codetabw.jpg

The below is an extract from my program:




Qt Code:
  1. [ATTACH=CONFIG]13697[/ATTACH]displaylb = QLabel("Selected row")
  2. self.displaytx = QLineEdit()
  3. self.displaytx.setReadOnly(True)
  4. self.tab = QtWidgets.QTableWidget(self)
  5. Headerlist = [this contains the columns title in the qTablewidget]
  6. self.tab.setRowCount(100000)
  7. self.tab.setColumnCount(15)
  8. self.tab.setHorizontalHeaderLabels(Headerlist)
  9. self.tab.horizontalHeader().setStyleSheet("::section{background-color: blue}")
  10. self.tab.setGeometry(150, 200, 1700, 1700)
  11. self.tab.setSizeAdjustPolicy(QAbstractScrollArea.AdjustToContents)
  12. self.tab.resizeColumnsToContents()
  13. #self.tab.setColumnWidth(0,150)
  14. self.tab.setSelectionBehavior(QAbstractItemView.SelectRows)
  15. self.tab.horizontalHeader().setSectionResizeMode(
  16. QHeaderView.Stretch) # this makes the columns fit in the widget
  17. self.tab.setEditTriggers(QtWidgets.QTableWidget.NoEditTriggers)
  18. self.tab.cellDoubleClicked.connect(self.tabClick)
To copy to clipboard, switch view to plain text mode