0

I am trying to insert pretty, HTML text into QTableWidget cells using setCellWidget and QTextEdit objects. This works great, but now my table doesn't get mouse clicks (for selection, etc.) or keypresses (for selection, navigation, etc.).

Here is how I'm setting up the cells:

ui.myTableWidget->insertRow(rowCount);

QTableWidgetItem *srcItem = new QTableWidgetItem();
ui.myTableWidget->setItem(rowCount, 0, srcItem);

QTextEdit *text = new QTextEdit();
text->insertHtml( _GetHTML() );
text->setFrameStyle( QFrame::NoFrame );
text->setReadOnly( true );
ui.myTableWidget->setCellWidget( rowCount, 0, text );

Thanks for suggestions.

Slogger
  • 1
  • 1

1 Answers1

0

I solved this problem by creating a delegate and painting the cell myself. I used a QTextDocument object to do the painting.

I referenced this example on delegates: http://doc.qt.io/qt-5/qtwidgets-itemviews-stardelegate-example.html

albertTaberner
  • 1,969
  • 1
  • 26
  • 35
Slogger
  • 1
  • 1