繁体   English   中英

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

[英]The slot setShowGride doesn't work in my app

是程序,这是屏幕截图

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

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,所以不需要它。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM