0

I am trying to make something like QtCreator log window. I am using QTableView with the following properties: - one column, - horisontalHeaderStretchLastSection = true - horizontalHeaderVisible = false - wordWrap = true - autoScroll = true - horizontalScrollBarPolicy = scrollBarAlwaaysOn

And I use the following code to insert new row into the table

modelView = new QStandardItemModel;
modelView ->setColumnCount(1);
modelView ->setRowCount(0);
ui->tableView->setModel(modelView );

QString msg = "Test Messege 1...................................................................................................................................................................END";
QStandardItem *row = new QStandardItem(msg);
modelView ->setRowCount(window->rowCount()+1);
modelView ->setItem(window->rowCount()-1, 0, row);

However, Neither the text wraps, nor the view is scrollable horizontally, only the content that is within the window size appears.

I get the following view:

enter image description here

Ahmed Waheed
  • 1,281
  • 5
  • 21
  • 39

1 Answers1

0

This answer worked for me https://stackoverflow.com/a/9547363/458999

Needed to call resizeRowsToContents after each row insertion

Community
  • 1
  • 1
Ahmed Waheed
  • 1,281
  • 5
  • 21
  • 39