如上图所示,组与其子记录用的都是QlistWidget,希望组更改时,不要立即显示它包含的子记录。
组切换记录时用的是信号:currentRowChanged
这里只说明如何用QTimer来实现延时处理.
ImListWidget::ImListWidget(QWidget *parent, bool bGroup)
: QListWidget(parent)
{
setContentsMargins(5, 0, 5 ,5);
setAutoScroll(false);
//当为组时,增加延时处理逻辑
if (bGroup){
connect(this,SIGNAL(currentRowChanged(int)),this, SLOT(slotCurrentRowChanged(int)));
m_atTime = new QTimer(this);
m_atTime->setInterval(1000);
m_atTime->setSingleShot(true);
connect(m_atTime, SIGNAL(timeout()), this, SLOT(slotDelayCurrentRowChanged()));
}
}
void ImListWidget::slotDelayCurrentRowChanged()
{
if (m_row>-1 && curre