Search code examples
c++qtsignals-slotsqt5.9

The slot setShowGride doesn't work in my app


Here is the program and here is the screenshot.

Here is also the code for the showGridAction (where I see issues in that) inside the: void MainWindow::createActions() function (in 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

My questions:

1- First I think the part #if QT_VERSION < 0x040102 until #endif is not needed anymore, because I'm using Qt 5.9. Do you think so too?

2- That code doesn't work in effect. As you can see from the screenshot above, checking and unchecking the Show Grid option makes no changes! How to make it work for the app please?

3- There is a slot in the code named setShowGride(bool). Where is it from? It won't be highlited when I click it and also takes me nowhere when I press F2 on it! It's probably the source of the issue for the option above not to function.
How to fix it please?


Solution

  • There is a typo in the code. If it is fixed the app runs correctly. Use setShowGrid not setShowGride.

    And about that part of the code, yes, it's not needed because you are using Qt 5.9.