Results 1 to 5 of 5

Thread: Widgets visual update / synchronization

  1. #1
    Join Date
    Mar 2006
    Posts
    142
    Thanks
    8
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Widgets visual update / synchronization

    Hello,
    I have a slot, whose code is below :
    this->Print("-> received");
    this->current_step->setText(QString::number(this->current_step->text().toInt()+1));
    this->update();
    this->Print("-> executed");
    current_text being a QLineEdit.
    My problem is that the slot is executed synchronously - I mean the prints occurs at the right time, i.e. immediately next to each computation step has been completed, BUT the number displayed in the QLineEdit is only updated after all steps have been completed. So there is a delay between the time at which the setText() is executed and the time at which the widget display is updated. How to cope with this issue?
    Thanks in advance for your help.

    Caius

  2. #2
    Join Date
    Sep 2007
    Location
    Szczecin, Poland
    Posts
    153
    Thanks
    7
    Thanked 11 Times in 8 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Widgets visual update / synchronization

    hi,
    two hints, first:
    void QWidget::update () [slot]
    Updates the widget unless updates are disabled or the widget is hidden.
    This function does not cause an immediate repaint; instead it schedules a paint event for processing when Qt returns to the main event loop. This permits Qt to optimize for more speed and less flicker than a call to repaint() does.
    so use repaint instead...
    Repaints the widget directly by calling paintEvent() immediately, unless updates are disabled or the widget is hidden.
    We suggest only using repaint() if you need an immediate repaint, for example during animation. In almost all circumstances update() is better, as it permits Qt to optimize for speed and minimize flicker.
    second - make sure that you have updatesEnabled property set to true.
    See GrEEn (Graphics Effects Environment)
    http://sourceforge.net/project/platf...roup_id=232746
    a qt-based plugins oriented MDI image processing application(contains also qt plugins like styles & imageformats).

  3. #3
    Join Date
    Aug 2006
    Posts
    250
    Thanks
    19
    Thanked 49 Times in 36 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Widgets visual update / synchronization

    QCoreApplication:rocessEvents()

  4. #4
    Join Date
    Mar 2006
    Posts
    142
    Thanks
    8
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Widgets visual update / synchronization

    Back to you.
    I have checked the updatesEnabled property, tried processEvents() call, but still does not work.
    I have also tried the QCoreApplication::flush() solution, as advised in the Qt documentation but nothing has changed.
    My display function appears as follow:

    class wlFieldImage : public QLabel
    {
    ...
    }

    FieldImage:: paintEvent(QPaintEvent *event)
    {
    printf("paint\n");
    [ some drawings ]
    QCoreApplication::flush();
    printf("paint done\n");
    }
    The prints appear during the simulation but the image display only appears at the end.
    Any help?

  5. #5
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Widgets visual update / synchronization

    How and where did you call processEvents()?

  6. The following user says thank you to wysota for this useful post:

    Caius Aérobus (29th November 2007)

Similar Threads

  1. Qt configure with msvc.net
    By jivanr in forum Installation and Deployment
    Replies: 1
    Last Post: 11th June 2007, 08:17
  2. Qt Cryptographic Architecture
    By vermarajeev in forum Qt Programming
    Replies: 6
    Last Post: 9th February 2007, 13:15
  3. problem with linking
    By mickey in forum Qt Programming
    Replies: 49
    Last Post: 12th August 2006, 21:41

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.