PDA

View Full Version : Qmessagebox cant stop looping



Devoraz
7th August 2009, 06:49
the qmessagebox is in the below void that will loop every 5 sec. and so the messagebox will popup every 5 sec as well, is there a way to let the message box just pop up once? but at the same time, the void is still looping every 5 sec??


void Node::updateData(int index)
{
//setNodeData(index);

DB_OPEN
NodeDb::DATA *pData;
pNodeDb->getData(index, &pData);

nodeData.temp= pData->temp;
nodeData.voltage = pData->voltage;
nodeData.type = pData->type;
nodeData.strength = pData->strength;
nodeData.re = pData->re;
nodeData.t_time_on = pData->t_time_on;

nodeData.fadeNumber=pData->fadeNumber;
nodeData.fadeTime =pData->fadeTime ;
nodeData.newNode=pData->newNode;
nodeData.deletedNode=pData->deletedNode;

setColor(nodeData.type);

if (pData->status == NodeDb::DS_MOVE)
{
newPos.setX(pData->xpos);
newPos.setY(pData->ypos);
advance();
}

if (nodeData.addr==0){
nodeData.fadeNumber = 255;//pData->fadeNumber;
//ap_counter=apcount;
updated = true;
update();
if (!updateTimerId)
{
updateTimerId = startTimer(200);
}
}

timeStamp.restart();

if (nodeData.addr!=0)
{
updated = true;
update();
if(nodeData.temp > ((alertTemp*9)/5+32.0)||(edStrength > alertDistance))
{
QSound::play("sound/alert.wav");
QMessageBox::critical(NULL, tr("Alert"), tr("High temperature is being detected!!!"));
}
}
}

wagmare
7th August 2009, 06:53
normal program operation ..
use static int variable ..


static int count = 0;
if(nodeData.temp > ((alertTemp*9)/5+32.0)||(edStrength > alertDistance))
{
QSound::play("sound/alert.wav");
if(count != 0){
QMessageBox::critical(NULL, tr("Alert"), tr("High temperature is being detected!!!"));
count + = 1;
}
}

franz
7th August 2009, 06:59
Or define your count variable in the class, thereby keeping the function reentrant.

yogeshgokul
7th August 2009, 07:02
Showing a message box, waits untill you manually close that. This is how GUI event loop works. So you can do one thing.
Popup the message box. And close it by code, don't wait user to click on that to close it. Something like this:


QMessageBox msgBox(bla,bla);
msgBox.show();
wait(n);
msgBox.close();

Devoraz
7th August 2009, 07:07
normal program operation ..
use static int variable ..


static int count = 0;
if(nodeData.temp > ((alertTemp*9)/5+32.0)||(edStrength > alertDistance))
{
QSound::play("sound/alert.wav");
if(count != 0){
QMessageBox::critical(NULL, tr("Alert"), tr("High temperature is being detected!!!"));
count + = 1;
}
}


hmmm the messagebox now doesnt appear..

yogeshgokul
7th August 2009, 07:07
I think your question is misunderstood. Got diverse replies.;);)

Devoraz
7th August 2009, 07:16
Showing a message box, waits untill you manually close that. This is how GUI event loop works. So you can do one thing.
Popup the message box. And close it by code, don't wait user to click on that to close it. Something like this:


QMessageBox msgBox(bla,bla);
msgBox.show();
wait(n);
msgBox.close();

but i wan the user to close it.

Devoraz
7th August 2009, 07:26
if (nodeData.addr!=0)
{
updated = true;
update();
static int count = 0;
if(nodeData.temp > ((alertTemp*9)/5+32.0)||(edStrength > alertDistance))
{
QSound::play("sound/alert.wav");
if(count == 0)
{
QMessageBox::critical(NULL, tr("Alert"), tr("High temperature is being detected!!!"));
count++;
}
}
}

it work with this. but still have problem. if the user never press OK, many more messagebox window will popup.

franz
7th August 2009, 07:33
Do the count++ before you open the messagebox.

wagmare
7th August 2009, 07:34
it work with this. but still have problem. if the user never press OK, many more messagebox window will popup.

use isVisible() condition along with the count condition ...

hey franz is right .. use the count before showing ..