Results 1 to 4 of 4

Thread: Update of lable / changing the cursor

  1. #1
    Join Date
    Feb 2010
    Posts
    3
    Qt products
    Qt/Embedded

    Default Update of lable / changing the cursor

    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

  2. #2
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Update of lable / changing the cursor

    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.
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  3. #3
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: Update of lable / changing the cursor

    Following link could be of interest for your: http://doc.trolltech.com/qq/qq27-responsive-guis.html. Also have a look at QApplication::setOverrideCursor().

  4. #4
    Join Date
    Feb 2010
    Posts
    3
    Qt products
    Qt/Embedded

    Default Re: Update of lable / changing the cursor

    QApplication:rocessEvents() now makes the job. Thanks for your help.

Similar Threads

  1. How to increase size of the header lable in QTreeView
    By grsandeep85 in forum Qt Programming
    Replies: 1
    Last Post: 21st October 2009, 09:59
  2. Replies: 2
    Last Post: 2nd October 2009, 15:32
  3. problem in lable
    By wagmare in forum Qt Programming
    Replies: 3
    Last Post: 17th December 2008, 13:21
  4. Cursor not changing
    By bpetty in forum Newbie
    Replies: 4
    Last Post: 17th July 2007, 15:13
  5. ummm...cursor not changing...
    By nupul in forum Qt Programming
    Replies: 7
    Last Post: 4th May 2006, 16:57

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.