Multiple updates on widget



  • Hello All
    I am using a QT Application in which there is a QScrollview Widget which gets regular notifications to update itself.
    Will QT amalgamate these items and make a single call to paintevent?
    Order of events may be:
    update()
    eventA
    eventB
    update()
    eventC

    Will the paintevent function will be called 2 times or only once?

    Regards
    Ritesh


  • Moderators

    It depends on number of factors. One of them is if Qt gets a chance to get back to event loop in between and if there are any other events pending. Qt has a mechanism of event compression but it applies in limited number of scenarios.
    In general you should not assume one way or the other.
    If you feel you're updating too often you can try to control it. One way is not to call update directly but some intermediate function that would check how much time passed from last update (e.g. with QElapsedTimer) and call update if needed. A similar effect you can achieve by blocking widget's ability to update for periods of time by using setUpdatesEnabled(false) on it.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.