QT Creator 如何建槽
本想继承一个槽,但是发现编译不过,只好新建一个槽,有些东西要设置,不过很简单
定义一个槽
Q_OBJECT//一定要加上
public:
SelfDifineTree();
virtual ~SelfDifineTree();
//Q_SIGNALS:
// void expanded(const QModelIndex &index);
public Q_SLOTS:
void itemclicked(const QModelIndex &index);
链接槽
SelfDifineTree::SelfDifineTree()
: QTreeView()
{
qDebug()<<"create this file";;
QObject::connect(this,SIGNAL(clicked(QModelIndex)),this,SLOT(itemclicked(QModelIndex)));
}
void SelfDifineTree::itemclicked(const QModelIndex &index){
qDebug()<<"expanded~~";;
//this->QTreeView::expanded(&index);
}
设置编译器