How to use Windows Message Loop and Qt Application Exec?
-
@YJCN
MFC is very old too :)Anyway i wonder with that line
if(msg->message==275)
means ? where did u get this magic number from ?
@mrjj
This my CMD programm codeint main (){ EdsCameraRef camera; EdsUInt32 tv; init_camera(camera); //start_liveview(camera); //TakePicture(camera); take_photo(camera,1,1000); //TakePhoto(); //dispose(camera); cout << "before message" << endl; MSG msg; while (GetMessage(&msg, NULL, NULL, NULL)) { cout << "in while" << " msg.message:"<<msg.message<<endl; TranslateMessage(&msg); cout << "TranslateMessage" << endl; DispatchMessage(&msg); // Ends up calling objectEventFnc cout << "DispatchMessage" << endl; break; } cout << "after message" << endl; EdsCloseSession(camera); cout << "EdsCloseSession(camera);"; EdsTerminateSDK(); system("pause"); return 0;
This is output
-
HI
ahh, so 275 is the ID for what SDK is doing.
So you call
init_camera(camera); in main window also ?
(and take_photo(camera,1,1000);
and camera is a member variable in main window so it doesn't run out of scope?but you never see 275 ? in natvieEvent?
-
HI
ahh, so 275 is the ID for what SDK is doing.
So you call
init_camera(camera); in main window also ?
(and take_photo(camera,1,1000);
and camera is a member variable in main window so it doesn't run out of scope?but you never see 275 ? in natvieEvent?
-
@mrjj Yes. I put the code(init_camera(camera) and take_photo(camera,1,1000) ) in Button's slot function, after taking picture, the programm can't enter callback function(handleObjectEvent) and there is no 275 in natvieEvent.
Hi
and just to be 100% sure
camera is NOT a local variable in Button's slot function, but in the .h file as a true member of
main maindiw (in .h file) ?
(im checking its not a death by scope issue)If unsure what i ask, please show full Button's slot function. :)
-
Hi
and just to be 100% sure
camera is NOT a local variable in Button's slot function, but in the .h file as a true member of
main maindiw (in .h file) ?
(im checking its not a death by scope issue)If unsure what i ask, please show full Button's slot function. :)
@mrjj This is Button's slot function code
void MainWindow::on_pushButton_2_clicked() { EdsCameraRef camera; init_camera(camera); //start_liveview(camera); //TakePicture(camera); take_photo(camera,1,1000); //TakePhoto(); //dispose(camera); cout << "before message" << endl; MSG msg; while (::GetMessage(&msg, NULL, NULL, NULL)) { TranslateMessage(&msg); DispatchMessage(&msg); // Ends up calling objectEventFnc break; } cout << "after message" << endl; EdsCloseSession(camera); cout << "EdsCloseSession(camera);"; EdsTerminateSDK(); }
-
@mrjj This is Button's slot function code
void MainWindow::on_pushButton_2_clicked() { EdsCameraRef camera; init_camera(camera); //start_liveview(camera); //TakePicture(camera); take_photo(camera,1,1000); //TakePhoto(); //dispose(camera); cout << "before message" << endl; MSG msg; while (::GetMessage(&msg, NULL, NULL, NULL)) { TranslateMessage(&msg); DispatchMessage(&msg); // Ends up calling objectEventFnc break; } cout << "after message" << endl; EdsCloseSession(camera); cout << "EdsCloseSession(camera);"; EdsTerminateSDK(); }
@YJCN said in How to use Windows Message Loop and Qt Application Exec?:
while (::GetMessage(&msg, NULL, NULL, NULL))
{
TranslateMessage(&msg);
DispatchMessage(&msg); // Ends up calling objectEventFnc
break;
}You execute this loop only once (because of the break).
Shouldn't you call break after you got the message you need?@mrjj camera is local :-) but I don't thin this is the issue here.
-
@YJCN said in How to use Windows Message Loop and Qt Application Exec?:
while (::GetMessage(&msg, NULL, NULL, NULL))
{
TranslateMessage(&msg);
DispatchMessage(&msg); // Ends up calling objectEventFnc
break;
}You execute this loop only once (because of the break).
Shouldn't you call break after you got the message you need?@mrjj camera is local :-) but I don't thin this is the issue here.
-
@YJCN said in How to use Windows Message Loop and Qt Application Exec?:
while (::GetMessage(&msg, NULL, NULL, NULL))
{
TranslateMessage(&msg);
DispatchMessage(&msg); // Ends up calling objectEventFnc
break;
}You execute this loop only once (because of the break).
Shouldn't you call break after you got the message you need?@mrjj camera is local :-) but I don't thin this is the issue here.
@jsulm said in How to use Windows Message Loop and Qt Application Exec?:
Shouldn't you call break after you got the message you need?
Indeed, the loop picks up the first message and that's it. What makes you think that message is the right/only one which needs to be processed this way? It could be any old message....
-
@jsulm said in How to use Windows Message Loop and Qt Application Exec?:
Shouldn't you call break after you got the message you need?
Indeed, the loop picks up the first message and that's it. What makes you think that message is the right/only one which needs to be processed this way? It could be any old message....
-
@YJCN
You have to do more than just comment out thebreak
, if that's what you're saying. If that's all you do the::GetMessage()
loop will never exit, and your code will never return fromon_pushButton_2_clicked()
, e.g. you cannot press it again to take another photo. Presumably you need to find out whatever is the final message your camera issues on taking a photo and exit the loop once that has been received. -
@YJCN
You have to do more than just comment out thebreak
, if that's what you're saying. If that's all you do the::GetMessage()
loop will never exit, and your code will never return fromon_pushButton_2_clicked()
, e.g. you cannot press it again to take another photo. Presumably you need to find out whatever is the final message your camera issues on taking a photo and exit the loop once that has been received.