![]() ![]() ![]() You'll see that clicking the PushButton will generate a data that's not resized correctly. If anyone would like to understand what I'm talking about, just download this example. So, if there are longer words in the middle, those words will get wrapped. I've tried tableResult->scrollToBottom() and it will only resize based on items at the bottom. TableResult->setSelectionMode(QAbstractItemView::SingleSelection) TableResult->setSelectionBehavior(QAbstractItemView::SelectRows) TableResult->setEditTriggers(QAbstractItemView::NoEditTriggers) Model->setEditStrategy(QSqlTableModel::OnManualSubmit) ![]() My codes QSqlTableModel *model = new QSqlTableModel So, my question is, how can I make sure those columns are resized to the max based on all of the data? It seems as if tableView didn't know there are longer text below. The weird thing is, if I scroll down to the bottom and refresh the data, tableView will resize those columns correctly. Which means that if I have more data below (which is longer in terms of counts of words), those words will be wrapped down (if the wordWrap property is set to true). It seems that tableView->resizeColumnsToContents() will only resize all the columns based on data in current view. viewport ().update () try using : ().update () Share. Use the update method of viewport to update the content of a tableview. I'm not sure how to ask this, so, feel free to ask for more information. QTableView instance has viewport which has update method through that we can update the table content.
0 Comments
Leave a Reply. |