Qt5自带的例程《chartthemes》,想加个timer事件,
但这个
widget是手动创建的,
qtimer加上后,
编译显示:
QObject::connect: invalid null parameter
创建timer:
- chartTimer=new QTimer(this);
- chartTimer->start(600);
信号槽连接:
- void ThemeWidget::connectSignals()
- {
- connect(m_themeComboBox,
- static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged),
- this, &ThemeWidget::updateUI);
- connect(m_antialiasCheckBox, &QCheckBox::toggled, this, &ThemeWidget::updateUI);
- connect(m_animatedComboBox,
- static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged),
- this, &ThemeWidget::updateUI);
- connect(m_legendComboBox,
- static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged),
- this, &ThemeWidget::updateUI);
- connect(chartTimer, &QTimer::timeout, this,&ThemeWidget::updateLineChart);
- }
最后一个connect是我后期增加的,其余为源码。
如果是在自动创建widget的情况下,标注的地方应该
没有问题。
但现在是手动创建widget窗体,在不考虑
事件的方式下,想请教下这个信号槽该怎么加?怎么理解?谢谢。