Reputation: 5073
I want to add a Table Widget
in my application. But some properties which I want are not supported for Table Widget
, but are available for QLineEdit
.
For example Validator
, PlaceHolderText
, etc properties from QLineEdit
. I want to have these properties for individual cells of Table Widget
. I don't want to add QLineEdit
in my GUI
, only Table Widget
.
Is it possible to do this?
Thank You.
Upvotes: 0
Views: 1301
Reputation: 56479
I think, you can change those cells to be a QLineEdit
by setCellWidget
, and use its functionality :
the_table_widget->setCellWidget(row, col, new QLineEdit);
Upvotes: 1
Reputation: 22346
Create a QStyledItemDelegate
subclass that draws the text or placeholder text as normal (it can do this without reimplementing), but produces a QLineEdit
as it's editor widget.
Add it using QTableWidget::setItemDelegate(QAbstractItemDelegate* delegate)
.
Upvotes: 3