Solved setGeometry crashes widget UI
-
Hello. I am trying to set my UI widget size to the size of a HWND handle obtained by FindWindowA function.
I am able to retrieve the size from the HWND handle, and i can see that my UI widget window is set to the correct size right before it crashes, what is going on?..The UI window crashes right after it is shown and i do not know why.
This is the code responsible for the size of the UI widget window:void DefuseHUD::WindowSize() { tagRECT *rect; GetWindowRect(FindWindowA(NULL, "Untitled - Notepad"), rect); this->setGeometry(rect->left, rect->top, rect->right - rect->left, rect->bottom - rec- >top); this->setWindowState((windowState())); }
and i call this function from another .cpp file like this:
DefuseHUD *hud = new DefuseHUD(); // create instance of UI widget window. hud->WindowSize(); hud->show();
-
You are accessing a dangling pointer.
tagRECT rect; Q_ASSUME(GetWindowRect(FindWindowA(NULL, "Untitled - Notepad"), &rect)); setGeometry(QRect(QPoint(rect.left, rect.top),QPoint(rect.right, rect.bottom)));
-
You are accessing a dangling pointer.
tagRECT rect; Q_ASSUME(GetWindowRect(FindWindowA(NULL, "Untitled - Notepad"), &rect)); setGeometry(QRect(QPoint(rect.left, rect.top),QPoint(rect.right, rect.bottom)));
-
@vronin said in setGeometry crashes widget UI:
n
My god thanks .. So that was it all along i guess. Appriciate the help!