2016-09-26 32 views
0

我正在嘗試做類似QtCreator日誌窗口。 我使用QTableView中具有以下屬性: - 一列, - horisontalHeaderStretchLastSection = true - horizontalHeaderVisible = false - wordWrap = true - autoScroll = true - horizontalScrollBarPolicy = scrollBarAlwaaysOnQTableView不滾動和文本不包裝

而且我用下面的代碼中插入新行插入表

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); 

但是,文本既不換行也不可以水平滾動視圖,只顯示窗口大小內的內容。

我得到以下觀點:

enter image description here

+0

開始後打電話到resizeRowsToContents刪除horizo​​ntalHeaderStretchLastSection – Fabio

+0

@Fabio沒有按」 t修復它。 –

回答