1

Iam new in Qt and I have problem how to pass QAction as parameter like this code:

connect(fileToolBarAct, SIGNAL(toggled(bool)), this, SLOT(ToggleBar(fileToolBarAct));

And this my slots function:

void MainWindow::ToggleBar(QAction& what)
{
    what.isCheckable();
}
4

2 回答 2

2

QObject::connect不能这样工作。您不能将对象传递给SIGNALSLOT宏。宏应该采用函数签名SIGNALSLOT此外the signature of a signal must match the signature of the receiving slot,如Qt文档中所述。

我发现您缺乏对信号和插槽机制的理解,我建议您阅读Qt Signals and Slots文档以获取更多信息。阅读Qt Signals and Slots文档将为您清除一切。

于 2014-12-02T15:15:51.010 回答
0
onnect(fileToolBarAct, SIGNAL(toggled(bool)), this, SLOT(ToggleBar(bool));


void MainWindow::ToggleBar(bool checked)
{
    QAction* action = qobject_cast<QOAction*>(sender());
    if (action) 
         action->setChecked(checked);
}
于 2014-12-06T05:43:29.567 回答