your code and variable usage is very difficult to understand, I think you have to write a clear code for people to pay attention your problem. Whatever, it seems that ptr_ie is a kind of container that holds structs in your code and you are creating new ptr_ie pointer to object each time your Get_ınfo function is called and also in print function your newly created ptr_ie is decalred without any initialization so of course you will reference unrelated part of your memory. Declare your input_events * ptr_ie as a private member in your Mainwindow class and define it in your constructor and remove ptr_ie declarations from your get_info and print function.