怎样实现qtableview也许qtablewidget的单元格自动换行
1个回答
2015-08-02
展开全部
bool QTableModel::removeRows(int row, int count, const QModelIndex &)
101{
102 if (count <1|| row <0|| row + count > verticalHeaderItems.count())
103 return false;
104
105 beginRemoveRows(QModelIndex(), row, row + count -1);
106 int i= tableIndex(row,0);
107 int n= count * columnCount();
108 QTableWidgetItem *oldItem=0;
109 for (int j= i; j < n + i; ++j) {
110 oldItem = tableItems.at(j);
111 if (oldItem)
112 oldItem->view =0;
113 delete oldItem;
114 }
115 tableItems.remove(qMax(i,0), n);
116 for (int v= row; v < row + count; ++v) {
117 oldItem = verticalHeaderItems.at(v);
118 if (oldItem)
119 oldItem->view =0;
120 delete oldItem;
121 }
122 verticalHeaderItems.remove(row, count);
123 endRemoveRows();
124 return true;
125}
void QTableModel::clear()
{
for (int j = 0; j < verticalHeaderItems.count(); ++j) {
if (verticalHeaderItems.at(j)) {
verticalHeaderItems.at(j)->view = 0;
delete verticalHeaderItems.at(j);; // <--
verticalHeaderItems[j] = 0;
}
}
101{
102 if (count <1|| row <0|| row + count > verticalHeaderItems.count())
103 return false;
104
105 beginRemoveRows(QModelIndex(), row, row + count -1);
106 int i= tableIndex(row,0);
107 int n= count * columnCount();
108 QTableWidgetItem *oldItem=0;
109 for (int j= i; j < n + i; ++j) {
110 oldItem = tableItems.at(j);
111 if (oldItem)
112 oldItem->view =0;
113 delete oldItem;
114 }
115 tableItems.remove(qMax(i,0), n);
116 for (int v= row; v < row + count; ++v) {
117 oldItem = verticalHeaderItems.at(v);
118 if (oldItem)
119 oldItem->view =0;
120 delete oldItem;
121 }
122 verticalHeaderItems.remove(row, count);
123 endRemoveRows();
124 return true;
125}
void QTableModel::clear()
{
for (int j = 0; j < verticalHeaderItems.count(); ++j) {
if (verticalHeaderItems.at(j)) {
verticalHeaderItems.at(j)->view = 0;
delete verticalHeaderItems.at(j);; // <--
verticalHeaderItems[j] = 0;
}
}
本回答被提问者和网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询
广告 您可能关注的内容 |