code1
code2
code3
i want to execute code 3 after 1sec delay from code2 execution.
Without timer can i do it??
I am using paintevent which is automatically called 10times/sec.
code1
code2
code3
i want to execute code 3 after 1sec delay from code2 execution.
Without timer can i do it??
I am using paintevent which is automatically called 10times/sec.
why not using QTimter?
Sounds like a design problem.
If you give more details on the scenario, we probably can help you find a better solution.
==========================signature=============== ==================
S.O.L.I.D principles (use them!):
https://en.wikipedia.org/wiki/SOLID_...iented_design)
Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.
i am developing a wordsearch game. when i selects a correct word a line should be drawn upon the selected word. if my selection is wrong the line drawn should be cleared after 200ms. I have started a timer after drawing the line in case of wrong selection and on timer time out i usedbut it does not works in a timer. it shows a visual studio runtime error. I guess its because the paint event is called continously.Qt Code:
painter->eraseRect(100,40,550,440);To copy to clipboard, switch view to plain text mode
Now i used the code write next to the line drawing. so i cant see the line for 200ms. but the sameshows no error when its used next with the drawline codeQt Code:
painter->eraseRect(100,40,550,440);To copy to clipboard, switch view to plain text mode
show your code.but it does not works in a timer. it shows a visual studio runtime error. I guess its because the paint event is called continously.
==========================signature=============== ==================
S.O.L.I.D principles (use them!):
https://en.wikipedia.org/wiki/SOLID_...iented_design)
Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.
Your design is totally wrong, I'm afraid. You are thinking in a synchronous way but using an asynchronous environment. And your painting is totally wrong as already stated in the other thread of yours. paintEvent is meant to paint the current state on a clear (erased) canvas. After 200ms state of your widget should change and that should trigger a repaint and not the other way round. You can't "update" the current painting, you need to redraw from the beginning.
Sorry, in an application that uses the GUI interfaces you should not (and in many cases MUST not) insert delay operations inline in your code. You need to learn how to think about things a bits of separate but interdependent code that are each triggered by events of some sort.
Bookmarks