PDA

View Full Version : QIconView refresh on returnPressed event



calin_iaru
21st February 2008, 09:46
I am debugging someone's code and I see a strange thing:
- when double click-ing on the icon, the iconview is re-created, each of the new items is positioned as before
- when pressing enter on an icon, the iconview is re-created, each of the new items is positioned as before and then the iconview is refreshed. The icons will expand to all the viewport space.

And here's the problem: both doubleClick and returnPressed signals are triggering the same function, but the result is different. The idea behind positioning the icons is to have them represent a 2D matrix. Their spatial presentation matters and I would need a mechanism that places the icons within a specified boundary.

calin_iaru
22nd February 2008, 12:41
This happens on Windows with 3.3.5 version of QT. Further debugging shows that eventFilter calls keyPressEvent and ensureItemVisible when the return key is pressed. The last function is responsible for arranging the items.

marcel
23rd February 2008, 06:49
So, isn't the same function called for a double click?

marcel
24th February 2008, 10:58
This happens on Windows with 3.3.5 version of QT. Further debugging shows that eventFilter calls keyPressEvent and ensureItemVisible when the return key is pressed. The last function is responsible for arranging the items.

Maybe posting some code would help, and also explain a bit what the behavior should be.

calin_iaru
25th February 2008, 15:04
Actually I made a blog entry at this address:
http://caliniaru.spaces.live.com/blog/cns!6AA12772441EBED0!138.entry

If you don't want to read it, here's what I found so far:
- returnPressed and doubleClicked are called from different contexts
- in case of returnPressed, the redraw of the icons is done by the built-in timer. I have subclassed the QIconView and redefined slotUpdate in order to prevent the timer mechanism.