展开全部
给你举个例子吧,比如右键treewidget中的一个item.
用
connect(ui->treeWidget, SIGNAL(itemPressed(QTreeWidgetItem *, int)),
this, SLOT(slotTreeWidget(QTreeWidgetItem *, int)));
来连接,槽函数为:
void Design::slotTreeWidget(QTreeWidgetItem *item, int column)
{
if (qApp->mouseButtons() == Qt::LeftButton) //左键
{
}
else //(qApp->mouseButtons() == Qt::RightButton) //右键
{
}
}
用
connect(ui->treeWidget, SIGNAL(itemPressed(QTreeWidgetItem *, int)),
this, SLOT(slotTreeWidget(QTreeWidgetItem *, int)));
来连接,槽函数为:
void Design::slotTreeWidget(QTreeWidgetItem *item, int column)
{
if (qApp->mouseButtons() == Qt::LeftButton) //左键
{
}
else //(qApp->mouseButtons() == Qt::RightButton) //右键
{
}
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询