How to Wrap the text in QTableView
-
Hi,
I want to wrap the text in QTableView. I am using these lines of code. but its not wraping. Please help me@QStandardItemModel model= new QStandardItemModel(row,1);
model->setColumnCount(1);
QString readString;
for (int r = 0; r < row; r++) {
for (int column = 0; column < 1; column++) {
QModelIndex mindex = model->index(r, column);
model->setData(mindex,readString);
}
}
HtmlDelegate delegate = new HtmlDelegate();
ui->tableView->setModel(model);
QHeaderView* hhdr = ui->tableView->horizontalHeader();
QHeaderView* vhdr = ui->tableView->verticalHeader();
for (int r = 0; r < row; r++) {
for (int column = 0; column < 1; column++) {
vhdr->setSectionResizeMode(r, QHeaderView::ResizeToContents);
hhdr->setSectionResizeMode(column, QHeaderView::Stretch);
}
}
ui->tableView->setWordWrap(true);
ui->tableView->setTextElideMode(Qt::ElideLeft);
ui->tableView->resizeColumnsToContents();
ui->tableView->resizeRowsToContents();ui->tableView->setItemDelegate(delegate);
@