插槽 setShowGride 在我的应用中不起作用

The slot setShowGride doesn't work in my app

Here is the program and here is the screenshot。

这也是 showGridAction 的代码(我在其中看到了问题):void MainWindow::createActions() 函数(在 MainWindow.cpp 中):

showGridAction = new QAction(tr("&Show Grid"), this);
    showGridAction -> setCheckable(true);
    showGridAction -> setChecked(spreadsheet -> showGrid());
    showGridAction -> setStatusTip(tr("Show or hide the spreadsheet's"
                                       " grid"));
    connect(showGridAction, SIGNAL(toggled(bool)),
            spreadsheet, SLOT(setShowGride(bool)));

#if QT_VERSION < 0x040102
    // workaround for a QTableWidget bug in Qt 4.1.1
    connect(showGridAction, SIGNAL(toggled(bool)),
            spreadsheet->viewport(), SLOT(update()));
#endif

我的问题:

1- 首先我认为 #if QT_VERSION < 0x040102#endif 部分不再需要了,因为我使用的是 Qt 5.9。你也这么认为吗?

2- 该代码无效。从上面的屏幕截图可以看出,选中和取消选中 Show Grid 选项没有任何变化!请问如何让它适用于应用程序?

3- 代码中有一个槽名为setShowGride(bool)。这个从哪里来?当我点击它时它不会高亮显示,当我按 F2 时它也不会带我去任何地方!这可能是上述选项不起作用的问题根源。
请问如何解决?

代码中有错字。如果它已修复,应用程序将正常运行。使用 setShowGrid 而不是 setShowGride

关于那部分代码,是的,不需要它,因为您使用的是 Qt 5.9。