C++ QT4 检测用户何时双击 qtablewidget 标题
我试图检测用户何时双击 qtablewidget 中的标题。为此,我将信号“sectionDoubleClicked(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*?
I am trying to detect when a user double clicks a header in a qtablewidget. To do this I am connecting to the signal "sectionDoubleClicked(int)" to a function with the same arguments (i got this from 1 ). My issue is that I am getting the following compile time error:
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
Here is my code:
QObject::connect(ui->table_results->horizontalHeader(),SIGNAL(sectionDoubleClicked(int)),
this,SIGNAL(headerclickedscan(int)));
do I just need to cast the result of horizontalHeader() to a QObject*?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您要么没有包含 QHeaderView
,要么没有在 MainWindow 类中声明“headerclickedscan(int)”作为信号。
另外,您确定希望“headerclickedscan(int)”成为信号而不是插槽吗?
You either didn't include QHeaderView by
or didn't declare "headerclickedscan(int)" as signal in your MainWindow class.
Also are you sure you want "headerclickedscan(int)" to be a signal but not a slot ?