C++ QT4 检测用户何时双击 qtablewidget 标题

发布于 2024-10-31 18:47:51 字数 944 浏览 3 评论 0原文

我试图检测用户何时双击 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)));

我是否只需要将 Horizo​​ntalHeader() 的结果转换为 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

×纯※雪 2024-11-07 18:47:51

您要么没有包含 QHeaderView

#include <QHeaderView>

,要么没有在 MainWindow 类中声明“headerclickedscan(int)”作为信号。

另外,您确定希望“headerclickedscan(int)”成为信号而不是插槽吗?

You either didn't include QHeaderView by

#include <QHeaderView>

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 ?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文