Frankly, I have trouble following the logic in your code and explanations.
And at least what you posted so far is very "scatchy" for me to see a specific one problem.
Again, instead of creating and deleting your dynamic widget, just use show() and hide() for it. (if you don't want to work with QDialog)
It is better for many reasons in comparison to creating deleting it all the time.
In addition to dangerous thins as not checking pointers have a look at this (see comments in code:
Qt Code:
  1. if(static Screen is visible)
  2. {
  3. hide static screen;
  4. }
  5.  
  6. if(dynscrn is object ! = NULL) //means dynamic widget is currently exist
  7. {
  8.  
  9. delete dynamic widget;
  10. dynamic widget = NULL;
  11. }
  12.  
  13. //you are showing (and for you showing = creating) a new dynamic widget, even if the
  14. // 'if' above was not true, resulting in a memory leak at best, and maybe other
  15. //problems such as you focus problems at worst.
  16. if(messageid == 500) //show dynamic scrn
  17. {
  18. create a dynamic widget from dynscrn and will be displayed by its constructor;
  19. }
  20. else //show static screen
  21. {
  22. ...
  23. }
To copy to clipboard, switch view to plain text mode