Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Native Development

Reply
Contributor
somedeveloperguy
Posts: 34
Registered: ‎10-08-2012
My Carrier: ??

Re: Open playbook camera in Qt project

thanks. it works now.

now I can start working on connecting it to Qt

Please use plain text.
BlackBerry Development Advisor
smcveigh
Posts: 651
Registered: ‎11-29-2011
My Carrier: other

Re: Open playbook camera in Qt project

Right.. static callbacks.. I mentioned this in my 1st response.

The reason for this, in case you are not a C++ coder, is that non-static C++ member functions have an implicit 1st argument (eg. myMethod(int i); is actually internally represented as myMethod(myClass* this, int i);  where "this" is a pointer to the class instance).  In a static function, there is no implicit "this" arguement.  When you are registering for callbacks in a C++ class, you should make sure to define them as static, since that is what is required by the callback function prototype, and you will probably also want to pass a "this" pointer into the function that register the callback in the void* argument position.  (eg. camera_take_photo()).  This allows your static callback to actually determine which class instance it should be referencing by examining the void* argument that it is called with.  The HelloCamera sample illustrates how to do this.

 

Cheers,

Sean

Please use plain text.
Contributor
somedeveloperguy
Posts: 34
Registered: ‎10-08-2012
My Carrier: ??

Re: Open playbook camera in Qt project

I have been trying a lot of things but I still can't get the camera to work with Qt.

I need to get the windowGroup and screencontext from the Qt window but I don't know how.

anyone have any experiance with this?

Please use plain text.
BlackBerry Development Advisor
smcveigh
Posts: 651
Registered: ‎11-29-2011
My Carrier: other

Re: Open playbook camera in Qt project

There was a thread on this maybe 2-3 weeks ago on this forum where these questions were answered.  Please use the search function and look for "video" or "camera".

 

Cheers,

Sean

 

Please use plain text.
BlackBerry Development Advisor
smcveigh
Posts: 651
Registered: ‎11-29-2011
My Carrier: other

Re: Open playbook camera in Qt project

Please use plain text.
Contributor
somedeveloperguy
Posts: 34
Registered: ‎10-08-2012
My Carrier: ??

Re: Open playbook camera in Qt project

i have come across that one a few days ago but i could nog get it to work.

 

if i try the way where you cast something to a screen_window_t and try to get the group_id from it, it will crash while creating a viewfinder with that group_id as a parameter.

 

and when i try the other way mentioned(the QPlatformNativeInterface) it will stop working while i try to get the windowgroup out of it.

Please use plain text.
Contributor
somedeveloperguy
Posts: 34
Registered: ‎10-08-2012
My Carrier: ??

Re: Open playbook camera in Qt project

i've been trying a lot of differend things over the last few days.

and the closest I have come so far is by placing the following code in the method i call when a button is pressed:

camera_handle_t handle;
    camera_error_t err;
    char test[200];
    screen_get_window_property_cv((screen_window_t)this->topLevelWidget()->winId(), SCREEN_PROPERTY_GROUP, 199, test);
    err = camera_open(CAMERA_UNIT_REAR, CAMERA_MODE_RW | CAMERA_MODE_ROLL, &handle);
    if(err != CAMERA_EOK){
        fprintf(stderr, "camera won't open\n");
    }
    err = camera_set_photovf_property(handle, CAMERA_IMGPROP_WIN_GROUPID, test, CAMERA_IMGPROP_WIN_ID, "something");
    if(err != CAMERA_EOK){
        fprintf(stderr, "setting photovf properties went wrong\n");
    }
    else{
        err = camera_start_photo_viewfinder(handle, NULL, NULL, NULL);
        fprintf(stderr, "past open viewfinder\n");
        return;
    }
    camera_close(handle);
    fprintf(stderr, "something went wrong, close all\n");

 I can see it starts the camera(when i open the camera app it will be black because camera is in use)

but it still does not open the viewfinder in my own application.

any idea why it won't show anything?

Please use plain text.
Trusted Contributor
cjonesy
Posts: 160
Registered: ‎09-13-2012
My Carrier: vodafone

Re: Open playbook camera in Qt project

[ Edited ]

I have been working with qt main window and native screens for the last couple of weeks and the following code works for me..

 

	char test[200];
	screen_get_window_property_cv((screen_window_t)window.winId(), SCREEN_PROPERTY_GROUP, 199, test);
	int x = 0;
	cout << "after join window "<<test;
	cout.flush();
	window.show();
	screen_create_context(&screen_ctx, 0);
	const int usage = SCREEN_USAGE_NATIVE;

	int rc;

	
	/* Setup the NATIVE window */

	rc = screen_create_window_type(&screen_win, screen_ctx, SCREEN_CHILD_WINDOW);
	cout << "createwindowtype " << rc;
	cout.flush();
	

	
	
	rc = screen_join_window_group(screen_win, test);
	

 

 

You also want to look out for the z order of the native screen, it is the child so set it to -1 to hide it and set it to 1 to show it (as long as there is only 2 windows).

Please use plain text.
Contributor
somedeveloperguy
Posts: 34
Registered: ‎10-08-2012
My Carrier: ??

Re: Open playbook camera in Qt project

please correct me if I am wrong, but what i understand from de code right now is the following:

- i make a Qt screen.

- i get its windowgroup with screen_get_window_property_cv

- i create a new screen_context_t

- i use the screen_context_t to create a new screen_window_t using screen_create_window_type with SCREEN_CHILD_WINDOW as its type.

- i join the window to the windowgroup with the name i got from screen_get_window_property_cv

 

I have tried everything i could find differend in your code from my own.

this includes changing: "screen_create_window(&screen_win,screen_ctx)" to "screen_create_window_type(&screen_win,screen_ctx,SCREEN_CHILD_WINDOW);",

replacing "screen_create_window_group(screen_win, vf_group)" with "screen_join_window_group(screen_win,vf_group);"

and adding the following to my code:

int z = 1;
screen_set_window_property_iv(screen_win, SCREEN_PROPERTY_ZORDER, &z);

 but when i press the button to start everything the new screen never comes.

Please use plain text.
Contributor
somedeveloperguy
Posts: 34
Registered: ‎10-08-2012
My Carrier: ??

Re: Open playbook camera in Qt project

one more interesting thing.

if I set z = 2 the backgroundscreen suddenly apears.

only the viewfiender of my camera is still nowhere to be found.

does someone know how to set the z value of a viewfinder.(because it is not a screen for some reason)

Please use plain text.