That dynamic cast will fail because main window is not related to qapplication. You should pass secondwindow ptr into read constructor. You shouldn't need to use statics.