Why the signal "dataChanged" by QTableWidget not work?
Hello, I am modifying the example "Chart" so that when I change data in the table, another function "Display()" can be executed. Below is my modification to MainWindow.cpp (line #17 is added to the original code):
Code:
MainWindow::MainWindow()
{
QAction *openAction
= fileMenu
->addAction
(tr
("&Open..."));
QAction *saveAction
= fileMenu
->addAction
(tr
("&Save As..."));
QAction *quitAction
= fileMenu
->addAction
(tr
("E&xit"));
setupModel();
setupViews();
connect(openAction, SIGNAL(triggered()), this, SLOT(openFile()));
connect(saveAction, SIGNAL(triggered()), this, SLOT(saveFile()));
connect(quitAction, SIGNAL(triggered()), qApp, SLOT(quit()));
menuBar()->addMenu(fileMenu);
statusBar();
openFile(":/Charts/qtdata.cht");
setWindowTitle(tr("Chart"));
resize(870, 550);
}
I am therefore expecting the following function written by my own (and added to prive slot in MainWindow.h) will be executed once I change data in the table view:
However, I found whatever I did to the data in the table view during execution of the main program, the display() function would never be triggered. Could anyone help me with this. I am using Qt 4.7 with visual studio 2008. Thank you very much.
Re: Why the signal "dataChanged" by QTableWidget not work?
I understand, It should be
connect(model, SIGNAL(dataChanged ( const QModelIndex &, const QModelIndex & )),
this, SLOT( backgroundChanged ( const QModelIndex & , const QModelIndex & )));
Then it works.