PDA

View Full Version : problem in lable



wagmare
17th December 2008, 12:10
hi friends,
I am using QLabel in the function and changing the text of the label in a regular interval but when i run the program the intermediate label text is not showing its text ...
if i use timer and it displaying but i cant use that for all label display so how can i solve that .... how to make regular interval of time b/w labels ....


please help

caduel
17th December 2008, 12:27
Some code would help us help you.

Does the event loop run between those settings of your QLabel's text?
(in other words: does Qt get a chance to (re)paint the updated label?)

HTH

wagmare
17th December 2008, 12:57
in class fingerprint including Ui.h file having a lable(msgLabel) and a pushbutton (capture)


class FingerPrint::FingerPrint()
{
setupUi(this);
msgLabel->setText("Click Capture");
connect(captureButton, SIGNAL(clicked()),this,SLOT(newPorting()));
}

in the connect slot calling a function returning CaptureImage()


void FingerPrint::newPorting()
{
QString out = "Put your finger.";
msgLabel->clear();
msgLabel->setText(out);
res = CaptureFunc();
if(res == 0)
{
originalPixmap = QPixmap();
msgLabel->setText("Image Captured..");
FPSLabel->setPixmap((QPixmap(QString::fromUtf8("Myimages/finger.bmp"))));
}
else
msgLabel->setText("Failed..");
}



in CaptureImage function


int FingerPrint::CaptureFunc()
{
some code ....
some code ....
msgLabel->clear();
msgLabel->setText("Capturing the image ...");

some code ....
some code ....
msgLabel->clear();
msgLabel->setText("Image Saved...");
return OK;
}






this is my code here first in my window it should display in lable msgLable "click capture"
next Put your finger and then inside Capture Image functions Capturing the image and last is Image Captured

this what i programmed but ...
its coming only ClickCapture at first then at last printing B]Image Captured[/B] in between text of msgLabel were not displaying ....

what is the exact problem .... please help .... :(

caduel
17th December 2008, 13:21
setText tells the QLabel to update its text...
QLabel will call update() to schedule a repaint...
that repaint will not be done right then, but rather when Qt has the time for it after your slot/event has finished and control flow has returned to the Qt event loop is.
If you have very long running slots, you need to
1) extract the long running op into a thread (and communicate with e.g. signals/slots); or
2) periodically call QCoreApplication::processEvents(); or
3) split that one slot into several (of course, you need some external triggers, to continue your "slot sequence")

HTH

PS: clear() is of no use when you directly call setText() after it.