QTreeView::rowsInserted internal
QTreeView::rowsInserted internal representation of the model has been corrupted, resetting.
我继承了一个QTreeWidget类,但是使用addTopLevelItem()时,执行的时候老是报下面的错误,有哪位遇到过?
给讲讲,怎么去除?
QTreeView::rowsInserted internal representation of the model has been corrupted, resetting.
项目进行中,很急,这个warning让boss很不满,
下面是源代码:
请帮忙解决一下,谢谢 !!!
#ifndef _TREE_WIDGET_H__
#define _TREE_WIDGET_H__
#include <QTreeWidget>
class TabPageWidget;
class TreeWidget:public QTreeWidget{
Q_OBJECT
public:
TreeWidget(TabPageWidget *pageParent,QWidget *parent=0);
~TreeWidget();
public:
//add a register path & icon
void addPath(const QIcon &icon,const QString &pathStr);
void addItem(const QIcon &icon,const QString &name,
const QString &descriptioin,const QString &publisher,
const QString &position);
public slots:
void updateInfowidget(QTreeWidgetItem *item,int column);
private:
TabPageWidget *parent;
};
#endif //_TABLE_WIDGET_H__
/*filename:tablewidget.cpp
*author:creatory@live.cn
*date:2009/12/27
*Copyright(C) Beijing HelpNow Network Co.,LTD.
*/
#include "../inc/treewidget.h"
#include "../inc/tabpagewidget.h"
#include <common.h>
#include <QHeaderView>
TreeWidget::TreeWidget(TabPageWidget *pageParent,QWidget *parent)TreeWidget(parent){
this->parent=pageParent;
//add four column headers
QStringList headerLabels;
headerLabels<<tr("名称"<<tr("描述"<<tr("出版者"<<tr("位置及参数"
setHeaderLabels(headerLabels);
header()->setResizeMode(QHeaderView::Interactive);
setColumnWidth(0,260);
setColumnWidth(1,200);
setColumnWidth(2,100);
setColumnWidth(3,500);
connect(this,SIGNAL(itemActivated(QTreeWidgetItem*,int)),this,SLOT(updateInfowidget(QTreeWidgetItem*,int)));
}
TreeWidget::~TreeWidget(){
}
void TreeWidget::addPath(const QIcon &icon,const QString &pathStr){
QTreeWidgetItem *item=new QTreeWidgetItem(this);
item->setText(0,pathStr);
item->setIcon(0,icon);
insertTopLevelItem(0,item);
}
void TreeWidget::addItem(const QIcon &icon,const QString &name,const QString &description,
const QString &publisher,const QString &position){
QTreeWidgetItem *item=new QTreeWidgetItem;
item->setIcon(0,icon);
item->setFlags(Qt::ItemIsUserCheckable|Qt::ItemIsEnabled|Qt::ItemIsSelectable);
item->setCheckState(0,Qt::Checked);
item->setText(0,name);
item->setText(1,description);
item->setText(2,publisher);
item->setText(3,position);
addTopLevelItem(item);
}
void TreeWidget::updateInfowidget(QTreeWidgetItem *item,int column){
DEBUG("updateInfowidgetn"
QString tmpStr;
for(int i=0;i<4;i++){
switch(i){
case 0:tmpStr+=tr("名称:"break;
case 1:tmpStr+=tr("描述:"break;
case 2:tmpStr+=tr("发行者:"break;
case 3:tmpStr+=tr("位置及参数:"break;
}
tmpStr+=item->text(i)+"n";
}
qDebug()<<tmpStr;
parent->updateInfoWidget(tmpStr);
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
求帮助啊,顶上来!