Results 1 to 20 of 20

Thread: update() works fine sometime but not everytime..!!

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,018 Times in 4,794 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: update() works fine sometime but not everytime..!!

    Quote Originally Posted by salmanmanekia View Post
    hmm..and why is so,i mean what factors decide when paintEvent() should be called on update and when it shouldnt..?
    If the widget is not visible, there is no point repainting it. When a repaint is already scheduled, there is no point in scheduling another one.

  2. #2
    Join Date
    Jan 2008
    Location
    Finland /Pakistan
    Posts
    216
    Thanks
    20
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: update() works fine sometime but not everytime..!!

    Quote Originally Posted by wysota View Post
    If the widget is not visible, there is no point repainting it. When a repaint is already scheduled, there is no point in scheduling another one.
    In my scenario widget is visible ,as i havent made it unvisible so i suppose it is visible by default.. i think my problem is regarding the second point i.e

    When a repaint is already scheduled, there is no point in scheduling another one.
    actually i am repainting continuously because i want to draw a progress bar which moves continuously but if the button is clicked then i want that progress bar to stop there and instead draw a progress status which means repaint again...
    so how to solve this ..??

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

    Default Re: update() works fine sometime but not everytime..!!

    Quote Originally Posted by salmanmanekia View Post
    actually i am repainting continuously because i want to draw a progress bar which moves continuously
    There is no such thing as doing something continuously in computers. Everything is digitized and quantified.

    but if the button is clicked then i want that progress bar to stop there and instead draw a progress status which means repaint again...
    so how to solve this ..??
    When you change the value of the progress bar, call update(). When you click the button - call update(). Never call update in other circumstances. Remember to allow events to be processed in the meantime.

  4. #4
    Join Date
    Jan 2008
    Location
    Finland /Pakistan
    Posts
    216
    Thanks
    20
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: update() works fine sometime but not everytime..!!

    There is no such thing as doing something continuously in computers. Everything is digitized and quantified.
    hmm...what i meant was that that it is being updated in 1 sec through timer...so that is what is continous..
    When you change the value of the progress bar, call update(). When you click the button - call update().
    to be precise i am calling it only in these two situation ,no More no Less,so why does it not update or calls paintEvent everytime...

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

    Default Re: update() works fine sometime but not everytime..!!

    So what does your code for changing the progress value and clicking the button look like? What is the timer connected to? If you have a custom paintEvent, please post it here as well.

  6. #6
    Join Date
    Jan 2008
    Location
    Finland /Pakistan
    Posts
    216
    Thanks
    20
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: update() works fine sometime but not everytime..!!

    thanks...i wasnt stopping the timer ,thats why sometime two updates() were running at the same time.....

  7. #7
    Join Date
    Jan 2008
    Location
    Finland /Pakistan
    Posts
    216
    Thanks
    20
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: update() works fine sometime but not everytime..!!

    i have one more question regarding the update and paintEvent(), my program is running fine but when i debug the code i see some unwanted behaviuor actually i want to draw one thing lets call it 'A' initially and wanted to draw other things depending on users input lets say it 'B,C,D...'..
    now 'A' should always be drawn no matter what 'B' ,'C' or 'D' is drawn but when i update it redraws A again and again..which is not required ,i only want the paintEvent to draw 'B','C' or 'D' for me not 'A' again and again ..but since it updates the view so to see 'A' again i have to redraw it every time...i want to some how define it in such a way that if 'A' is drawn one time it remains on screen no matter how many other updates are done..
    i hope you understand..!!

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

    Default Re: update() works fine sometime but not everytime..!!

    Can you post your paintEvent()?

  9. #9
    Join Date
    Jan 2008
    Location
    Finland /Pakistan
    Posts
    216
    Thanks
    20
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: update() works fine sometime but not everytime..!!

    PaintEvent Function:
    -----------------------
    Qt Code:
    1. QPainter painter(this);
    2. painter.setPen(QPen(grayBrush, ....
    3. painter.drawEllipse(OUTER_ELLIPSE_X,...
    4.  
    5. if(trials_completed >= 1)
    6. {
    7. painter.setPen(QPen(greenBrush,30,....
    8. if(trials_completed == 1)
    9. {
    10. qDebug() << "Draws The First Green Sequence ";
    11. ..// painting done here
    12. }
    13. else if(trials_completed == 2)
    14. {
    15. qDebug() << "Draws The First Two Green Sequence ";
    16. ..// painting done here
    17. }
    18. else if(trials_completed == 3)
    19. {
    20. qDebug() << "Draws The First Three Green Sequence ";
    21. ..// painting done here
    22. }
    23. else if(trials_completed == 4)
    24. {
    25. qDebug() << "Draws The Four Green Sequence ";
    26. ..
    27. }
    28. }
    29. if (rec_button == FALSE && accept_press == TRUE )
    30. {
    31. ..painting done depending on the button press by the user..
    32. }
    To copy to clipboard, switch view to plain text mode 

  10. #10
    Join Date
    Jan 2008
    Location
    Finland /Pakistan
    Posts
    216
    Thanks
    20
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: update() works fine sometime but not everytime..!!

    if any other info is required do tell me...

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

    Default Re: update() works fine sometime but not everytime..!!

    Quote Originally Posted by salmanmanekia View Post
    now 'A' should always be drawn no matter what 'B' ,'C' or 'D' is drawn but when i update it redraws A again and again..which is not required
    Why is it not required? You said it should be drawn each time.

    ,i only want the paintEvent to draw 'B','C' or 'D' for me not 'A' again and again ..but since it updates the view so to see 'A' again i have to redraw it every time...i want to some how define it in such a way that if 'A' is drawn one time it remains on screen no matter how many other updates are done..
    This is not possible. You have to draw it every time.

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
  •  
Qt is a trademark of The Qt Company.