当前位置: 代码迷 >> QT开发 >> Qt中发送一个信号,slot函数没有完成,再发一个相同的信号会怎样解决思路
  详细解决方案

Qt中发送一个信号,slot函数没有完成,再发一个相同的信号会怎样解决思路

热度:121   发布时间:2016-04-25 03:05:38.0
Qt中发送一个信号,slot函数没有完成,再发一个相同的信号会怎样
void CLabel::mousePressEvent(QMouseEvent *e)
{
if(e->button()==Qt::LeftButton)
{
setMousePressFlag(true);
emit signalLabelPress(this);
}

connect(label, SIGNAL(signalLabelPress(CLabel*)), this, SLOT(slotChangeCurrentPage(CLabel*)));

void DataBrain::slotChangeCurrentPage(CLabel *label)
{
int index = 0;

for (int i = 0; i < WINDOW_PAGE_COUNT; i++)
{
if (label == m_pLabelBtnArray[i])
{
index = i;
break;
}
}

if (index < m_currentFgIndex)
{
while(index != m_currentFgIndex)
{
m_currentFgIndex--;
moveCurrentPage(false);
}
}
else if (index > m_currentFgIndex) //点击右边的按钮 左移
{
while(index != m_currentFgIndex)
{
m_currentFgIndex++;
moveCurrentPage(true);
}
}
}

------解决思路----------------------
主线程里按顺序执行,第一个没运行完,不会运行第二个。
不使用多线程读写一个大文件,连界面都会被卡住,就是这个原因。