Results 1 to 6 of 6

Thread: update() in QWidget

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

    Default update() in QWidget

    Hi all !
    i want to repaint my widget at a signal of a button Clicked but with different picture,
    initially the paintEvent should contain a progress bar and after the button is clicked another bar should move in the progress bar showing the progress,so how to repaint/update the paintEvent() but now including the small progress bar moving,should it be done in the same paintEvent function ..!!
    i hope it is clear ..

  2. #2
    Join Date
    Jan 2006
    Posts
    667
    Thanks
    10
    Thanked 80 Times in 74 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: update() in QWidget

    Yes, I think you will need to either call QWidget::update or QWidget::repaint slot. It will in turn trigger paintEvent and then you can repaint your widget accordingly.

  3. The following user says thank you to munna for this useful post:

    salmanmanekia (28th July 2008)

  4. #3
    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() in QWidget

    ya,ya..may be i wasnt able to convey my question properly..anyway i will try again..
    i know that if you want to repaint the widget then update slot should be called ,but now the picture which i want to draw is different so if i just call the update() the paintEvent() would be called and will draw the same picture which it drew the first time...but this time i want something else (i.e someother picture) as well as the original (i.e first time) picture

  5. #4
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: update() in QWidget

    But what is the problem? Just create a function which changes the internal image and calls update(). Or use built-in widgets like QLabel which does it automatically for you.
    J-P Nurmi

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

    salmanmanekia (28th July 2008)

  7. #5
    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() in QWidget

    the problem is that that i think all the painting should be done in paintEvent() which can be trigger by update() but now i want the previous and the new picture on the click of button..
    i am exactly not sure how to put my code for repainting in paintEvent() because when ever i will call update() ,paintEvent() will do the same work,but now i want different work...

  8. #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() in QWidget

    ya,the problem is solved ,i just dig into what jpn suggested and it worked..Thanks

Similar Threads

  1. Dynamic updates of a QWidget in a QScrollArea
    By plamkata in forum Qt Programming
    Replies: 2
    Last Post: 21st July 2008, 00:45
  2. Display a QWidget using multi-screen
    By tarod in forum Qt Programming
    Replies: 3
    Last Post: 30th June 2008, 15:02
  3. Error in put one QWidget in another QWidget
    By xjtu in forum Qt Programming
    Replies: 1
    Last Post: 19th April 2008, 17:05
  4. QPainter update()
    By csvivek in forum Qt Programming
    Replies: 5
    Last Post: 24th March 2008, 10:42
  5. Replies: 3
    Last Post: 8th March 2007, 15:54

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.