widget.cpp: In constructor ‘Widget::Widget(QWidget*)’:
widget.cpp:10:17: error: ‘class Ui::Widget’ has no member named ‘treeWidget’
widget.cpp: In member function ‘void Widget::init()’:
widget.cpp:15:13: error: ‘class Ui::Widget’ has no member named ‘treeWidget’
widget.cpp:16:57: error: ‘class Ui::Widget’ has no member named ‘treeWidget’
widget.cpp:42:57: error: ‘class Ui::Widget’ has no member named ‘treeWidget’
widget.cpp: In member function ‘void Widget::treeItemChanged(QTreeWidgetItem*, int)’:
widget.cpp:74:34: warning: unused variable ‘parent’
widget.cpp: At global scope:
widget.cpp:68:14: warning: unused parameter ‘column’
make: *** [widget.o] 错误 1
#include <QWidget>
#include<QTreeWidgetItem>
#include "ui_widget.h"
Widget::Widget(QWidget *parent) :
QWidget(parent),
ui(new Ui::Widget)
{
ui->setupUi(this);
init();
connect(ui->treeWidget,SIGNAL(itemChanged(QTreeWidgetItem *,int)),
this,SLOT(treeItemChanged(QTreeWidgetItem *,int)));
}
void Widget::init()
{
ui->treeWidget->clear();
QTreeWidgetItem *group1=new QTreeWidgetItem(ui->treeWidget);
group1->setText(0,"group1");
group1->setFlags(Qt::ItemIsUserCheckable|Qt::ItemIsEnabled|Qt::
ItemIsSelectable);
group1->setCheckState(0,Qt::Unchecked);
QTreeWidgetItem *subItem11=new QTreeWidgetItem(group1);
subItem11->setFlags(Qt::ItemIsUserCheckable|Qt::ItemIsEnabled|Qt::
ItemIsSelectable);
subItem11->setCheckState(0,Qt::Unchecked);
QTreeWidgetItem *subItem12=new QTreeWidgetItem(group1);
subItem12->setFlags(Qt::ItemIsUserCheckable|Qt::ItemIsEnabled|Qt::
ItemIsSelectable);
subItem12->setText(0,"subItem12");
subItem12->setCheckState(0,Qt::Unchecked);
QTreeWidgetItem *subItem13=new QTreeWidgetItem(group1);
subItem13->setFlags(Qt::ItemIsUserCheckable|Qt::ItemIsEnabled|
Qt::ItemIsSelectable);
QTreeWidgetItem *subItem14=new QTreeWidgetItem(group1);
subItem14->setFlags(Qt::ItemIsUserCheckable|Qt::ItemIsEnabled|
Qt::ItemIsSelectable);
subItem14->setText(0,"subItem14");
subItem14->setCheckState(0,Qt::Unchecked);
//第二个分组
QTreeWidgetItem *group2=new QTreeWidgetItem(ui->treeWidget);
group2->setText(0,"group2");
group2->setFlags(Qt::ItemIsUserCheckable|Qt::ItemIsEnabled|
Qt::ItemIsSelectable);
group2->setCheckState(0,Qt::Unchecked);
QTreeWidgetItem *subItem21=new QTreeWidgetItem(group2);
subItem21->setFlags(Qt::ItemIsUserCheckable|Qt::ItemIsEnabled|
Qt::ItemIsSelectable);
subItem21->setText(0,"subItem21");
subItem21->setCheckState(0,Qt::Unchecked);
QTreeWidgetItem *subItem22=new QTreeWidgetItem(group2);
subItem22->setFlags(Qt::ItemIsUserCheckable|Qt::ItemIsEnabled|
Qt::ItemIsSelectable);
subItem22->setText(0,"subItem22");
subItem22->setCheckState(0,Qt::Unchecked);
QTreeWidgetItem *subItem23=new QTreeWidgetItem(group2);
subItem23->setFlags(Qt::ItemIsUserCheckable|Qt::ItemIsEnabled|