当用户双击qtablewidget标题时,c++ QT4检测

C++ QT4 detecting when a user double clickes a qtablewidget header

本文关键字:c++ QT4 检测 标题 用户 双击 qtablewidget      更新时间:2023-10-16

我试图检测用户何时双击qtablewidget中的标题。为此,我将信号"sectiondoubleclick (int)"连接到具有相同参数的函数(我从1中得到了这个)。我的问题是,我得到以下编译时错误:

mainwindow.cpp:117: error: no matching function for call to âMainWindow::connect(QHeaderView*, const char [27], MainWindow* const, const char [24])â
/usr/lib64/qt4/include/QtCore/qobject.h:181: note: candidates are: static bool QObject::connect(const QObject*, const char*, const QObject*, const char*, Qt::ConnectionType)
/usr/lib64/qt4/include/QtCore/qobject.h:282: note:                 bool QObject::connect(const QObject*, const char*, const char*, Qt::ConnectionType) const
下面是我的代码:
QObject::connect(ui->table_results->horizontalHeader(),SIGNAL(sectionDoubleClicked(int)),
              this,SIGNAL(headerclickedscan(int)));

我只需要将horizontalHeader()的结果转换为QObject*吗?

您要么没有包含QHeaderView

#include <QHeaderView>

或者没有在MainWindow类中声明"headerclickedscan(int)"作为信号

也你确定你想要"headerclickedscan(int)"是一个信号,而不是一个插槽?