QTableWidget中修改数据如何发出SIGNAL

weixin_38065454 2019-09-19 07:14:53
我修改了一下QT官网上的Chart的例子,在MainWindow.CPP中加入(粗体标出):MainWindow::MainWindow(){    QMenu *fileMenu = new QMenu(tr("&File"), this);    QAction *openAction = fileMenu->addAction(tr("&Open..."));    openAction->setShortcuts(QKeySequence::Open);    QAction *saveAction = fileMenu->addAction(tr("&Save As..."));    saveAction->setShortcuts(QKeySequence::SaveAs);    QAction *quitAction = fileMenu->addAction(tr("E&xit"));    quitAction->setShortcuts(QKeySequence::Quit);    setupModel();    setupViews();    connect(openAction, SIGNAL(triggered()), this, SLOT(openFile()));    connect(saveAction, SIGNAL(triggered()), this, SLOT(saveFile()));    connect(quitAction, SIGNAL(triggered()), qApp, SLOT(quit()));   connect (model,SIGNAL(dataChanged(const QModelIndex & topLeft, const QModelIndex & bottomRight)),this,SLOT(display(const QModelIndex & topLeft, const QModelIndex & bottomRight)));    menuBar()->addMenu(fileMenu);    statusBar();    openFile(":/Charts/qtdata.cht");    setWindowTitle(tr("Chart"));    resize(870, 550);}我是想程序执行的时候如果修改了Table中的数据,则能够触发void  display(const QModelIndex & topLeft, const QModelIndex & bottomRight);这个我写的函数,但是发现程序执行的时候,无论我在表中怎么修改,都不会执行display(),请问这是为什么呢?期盼有高手帮我解答下这个问题。谢谢!
...全文
37 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复

433

社区成员

发帖
与我相关
我的任务
社区描述
其他技术讨论专区
其他 技术论坛(原bbs)
社区管理员
  • 其他技术讨论专区社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧