0
self.ui.tableWidget.itemDoubleClicked.connect(self.select_item_on_double_clicked)

for row, value in enumerate([1, 2, 3, 4], 0):
    widget = QtWidgets.QWidget()
    widgetText = QtWidgets.QLabel(f"{value}")
    widgetLayout = QtWidgets.QHBoxLayout()
    widgetLayout.addWidget(widgetText)
    widgetLayout.setSizeConstraint(QtWidgets.QLayout.SetFixedSize)
    widget.setLayout(widgetLayout)
    self.ui.tableWidget.setCellWidget(row, 0, widget)

def select_item_on_double_clicked(self, item):
    print(item.row())

My question is my table has qlabel widget in 0th column, but when I double clicked on 0th column, double click event is not working.

eyllanesc
  • 235,170
  • 19
  • 170
  • 241
  • It's not emitted because you're double clicking the label. Is there a specific reason for using a label instead of setting the item data? – musicamante Jul 08 '21 at 22:03
  • yes, in label i want to show some html text, and html text is not possible in qtableview in specific cell.. so i kind of like stuck there, my double click signal not working. is there something another approach for this. please help – Rishabh Bhardwaj Jul 17 '21 at 15:12
  • Actually, I forgot that QLabel is transparent to mouse events (unless text interaction is set). Please provide a [mre], as the code you're showing us should work. – musicamante Jul 17 '21 at 15:22
  • Also, see this answer: https://stackoverflow.com/a/53572278 – musicamante Jul 17 '21 at 15:25
  • Actually i need full fledge html type thing which i think qlabel is capable of doing. and my project code is actually pretty big and completed, its hard for me to reproduce minimal example, the one i asked in question should be consider. thanks – Rishabh Bhardwaj Jul 17 '21 at 15:41
  • All i need is double clicking event signal in a qtablewidget cell so that i can get which cell is clicked from which rows and columns – Rishabh Bhardwaj Jul 17 '21 at 15:43
  • As said, based on the code you provided, it should work (I just tried it), so without an actual MRE we cannot help you. – musicamante Jul 17 '21 at 15:47

0 Answers0