A
A
Alexander Afanasiev2016-08-16 09:53:13
Qt
Alexander Afanasiev, 2016-08-16 09:53:13

How to get selected text in QTableWidgetItem?

There is a QTableWidgetItem. it is necessary to receive a part of the text from QTableWidgetItem which was selected by the user. How can this be done? or maybe replace QTableWidget with something else?
and question 2: in order for the text to become editable, you need to double-click on the QTableWidgetItem. Is there a way to make it enter edit mode right away?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
X
xibir, 2016-08-16
@XanderEVG

one:

if (QLineEdit* cw = dynamic_cast<QLineEdit*>(m_tableWidget->cellWidget(m_tableWidget->currentRow(), m_tableWidget->currentColumn())))
      qDebug() << cw->selectedText();

2:
m_tableWidget->setEditTriggers(QAbstractItemView::AllEditTriggers);

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question