【问题标题】:C++ QT4 detecting when a user double clickes a qtablewidget headerC++ QT4 检测用户何时双击 qtablewidget 标题
【发布时间】:2011-04-13 03:21:11
【问题描述】:

我试图检测用户何时双击 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* 吗?

【问题讨论】:

    标签: c++ qt4 signals-slots qtablewidget


    【解决方案1】:

    你要么没有包含 QHeaderView

    #include <QHeaderView>
    

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

    您还确定要将“headerclickedscan(int)”作为信号而不是插槽吗?

    【讨论】:

    • 你的权利,我要让插槽没有信号。解决了这个问题。谢谢。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-09-03
    • 2014-06-26
    相关资源
    最近更新 更多