【问题标题】:The slot setShowGride doesn't work in my app插槽 setShowGride 在我的应用程序中不起作用
【发布时间】:2017-08-10 19:30:54
【问题描述】:

Here 是程序,这里是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 &lt; 0x040102 直到 #endif 部分不再需要,因为我使用的是 Qt 5.9。你也这么认为吗?

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

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

【问题讨论】:

    标签: c++ qt signals-slots qt5.9


    【解决方案1】:

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

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

    【讨论】:

      猜你喜欢
      • 2022-11-11
      • 2014-12-12
      • 2020-01-27
      • 2016-07-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多