PDA

View Full Version : Update of lable / changing the cursor



mw0001
16th February 2010, 10:58
Hi there,

I'm writing a graphical frontend in Java using QT Jambi for the gui parts.
Now I've ran into some newbie problems with updating a lable and the changing of the mouse cursor :)

After programm start I want the user to log in. Herefor I did a QWidget with a lineedit for Username and password, a lable for messages and a pushbutton to start the login. After the button is clicked, the following method starts:


private void login()
{
User user = new User();
ILoginClient loginClient = new RestLoginClient();
ui.labelMessage.setText("Loggin in. Please wait!");
QCursor cursor = new QCursor();
cursor.setShape(CursorShape.BusyCursor);
this.setCursor(cursor);
[...]

When the method is called I want to update the Messagelable with the new text and set the cursor to Busy. After that I go on with the login. What's happening is, that the lable and the cursor change after my login is completed.

From earlier VB-times I know there has been a DoEvents-Command to give the OS the chance to redraw the elements of a window.
Do I need something simmilar here?

Thanks for your help in advance :)
Michael

high_flyer
16th February 2010, 11:46
From earlier VB-times I know there has been a DoEvents-Command to give the OS the chance to redraw the elements of a window.
Do I need something simmilar here?
You probably mean QApplication::processEvents().

But that is only needed, if you are blocking the the GUI thread, which is not a good practice, it would be better if you put your blocking code in a separate thread.

Could it be though, that the code before the cursor code indeed logs in?
In that case moving the Cursor code to the beginning of the method will give the cursor change like you want it.

Lykurg
16th February 2010, 13:50
Following link could be of interest for your: http://doc.trolltech.com/qq/qq27-responsive-guis.html. Also have a look at QApplication::setOverrideCursor().

mw0001
24th February 2010, 08:15
QApplication::processEvents() now makes the job. Thanks for your help.