After debugging, I found that an empty QWidget window is created after QApplication::syncX(),but is destroyed as it exits the function.
Also the State is changing successfully as it does not enter the if condition and directly exit.
What should I do to retain the window and successfully overlay the gstreamer stream over it??
Thank you very much,the approach worked seamlessly.
I was creating QWidget on stack and hence,it was getting destroyed.
Created it on heap and the problem solved.Created like this:
QWidget *wid = new QWidget(this);