PDA

View Full Version : Refresh my Qt window



maarvi
8th May 2011, 16:56
hello every one i am having a problem that i have a listview in my Qt creator program
and values of list is changing after few seconds i have called a time event.it is working fine as i can see my changing values of list but the problem is that the changing values seems to be visible when i minimize and the maximize the window or when i resize it.
is there any refresh type thing.
how can i view the the change in my list with out doing this resize or min max thing
hope you people getting what i want to say

kindly help me

thanks alot

rsilva
8th May 2011, 17:17
You can call update or updateGeometry function or can also send a resizeEvent with no change I think.

maarvi
8th May 2011, 17:28
ok sir thanks alot can you please give me a little more detail. i will be very thankful

rsilva
8th May 2011, 17:59
When you resize a window it need to repaint the child windows. So, you can force the repainting after changing these values.

To force repainting I think you can try this: (I've never needed to do this, but I think it will work)

You can call this function (recommended):

void QWidget::update() [slot]
And if it doesn't work you can try:

void QWidget::repaint() [slot]

In the help you can find this notes:

About update:
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.

Warning about using repaint:
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.


I think calling the update will work.

maarvi
8th May 2011, 18:10
thanks so much 4 your concern but its still not working:crying::(

Added after 7 minutes:

i have write code like
QWidget q;
q.update();

am i writing it correctly i mean that what is QWidget in my case

(sorry if my questions are annoying i am completely new to qt)

rsilva
8th May 2011, 20:21
The QListWidget is derived from QWidget.
So, to update a list widget, call the member function ^^.
Just do this:



// Don't declare a new QListWidget for calling update,
// just call the update from the one that you're using in the window.

listWidget->update();

Zlatomir
8th May 2011, 20:31
If rsilva advice doesn't work, tell us your Qt version and the OS - if i remember correctly there was a similar bug in Qt version ~4.5

//i'm not sure about version number and not sure if the QListWidget had the update bug - i just remember that i saw sometime ago a similar problem caused by a bug.