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
Trusted Contributor
Posts: 160
Registered: ‎09-13-2012
My Device: 9900
My Carrier: vodafone

Qt/native window - can receive screen events but not swipe down

[ Edited ]

Hi all,

 

I have a video being played in a child native window of a parent qt main window.

 

I have general sample handle event, handle navigator event and handle screen event in a thread looping.

 

The screen events are caught but the swipe down event isn't caught. I have succesfully caught using keypress when the video isn't playing but when the video window is shown the keypress function doesnt get called.

 

Whats the best way to do this?

 

Thanks

 

p.s the thread code looks like this

 

bps_initialize();
screen_request_events(externalscreencontext);
navigator_request_events(0);

while (!exit_application) {
/* Handle user input */
handle_events();
}

Developer
Posts: 1,068
Registered: ‎11-24-2011
My Device: PlayBook
My Carrier: x

Re: Qt/native window - can receive screen events but not swipe down

It would be interesting to see how you mix Qt and Native events handling.

Trusted Contributor
Posts: 160
Registered: ‎09-13-2012
My Device: 9900
My Carrier: vodafone

Re: Qt/native window - can receive screen events but not swipe down

Well I was catching the swipe as mentioned using keypress but when my video (native window) is shown it wasn't firing so i started a thread which just does what i posted in the last post - loop listening for screen and navigation events.

 

Is this ok? (I had it working pretty similar before I lost my code yesterday)

Developer
Posts: 1,068
Registered: ‎11-24-2011
My Device: PlayBook
My Carrier: x

Re: Qt/native window - can receive screen events but not swipe down

Sorry I can't advise as I still don't get it how you combine Qt and Native windows.

Trusted Contributor
Posts: 160
Registered: ‎09-13-2012
My Device: 9900
My Carrier: vodafone

Re: Qt/native window - can receive screen events but not swipe down

I combine by first creating and showing (mywindow)QMainWindow and getting it's window id and then joining my native window to that group..

 

screen_get_window_property_cv((screen_window_t)mywindow.winId(), SCREEN_PROPERTY_GROUP, 199, test);

 

screen_join_window_group(nativescreen_win, test);

 

Then I just add stuff to my window or create qdialogs to show other screens or just blit video data to nativescreen_win.

Trusted Contributor
Posts: 160
Registered: ‎09-13-2012
My Device: 9900
My Carrier: vodafone

Re: Qt/native window - can receive screen events but not swipe down

Also, when I press connect (for example) I then start the keyboard thread which loops listening for screen and navigation events after initialising bps (as shown earlier).

Developer
Posts: 1,068
Registered: ‎11-24-2011
My Device: PlayBook
My Carrier: x

Re: Qt/native window - can receive screen events but not swipe down

To create Native Window (before joining it to a group) you need to know screen context id, how do you get it?

Trusted Contributor
Posts: 160
Registered: ‎09-13-2012
My Device: 9900
My Carrier: vodafone

Re: Qt/native window - can receive screen events but not swipe down

http://supportforums.blackberry.com/t5/Native-Development/How-can-I-create-a-ui-with-my-code-for-2-1...

 

The first argument window.win_id() is cast and does the trick for me - there was another way suggested earlier in that thread from mcguire but i couldnt get that way to work.

Developer
Posts: 1,068
Registered: ‎11-24-2011
My Device: PlayBook
My Carrier: x

Re: Qt/native window - can receive screen events but not swipe down

On that forum thread you create screen context:

screen_create_context(&screen_ctx, 0);

if you are still doing it then it might be wrong as Qt creates its own screen context by calling the same function and you don't need to create another one. When I worked on Native+OpenGL windows example I was told by RIM that it is wrong to call screen_create_context twice.

But this is just 'side node' and probably is not related to your issue, I was just curious how you got screen context from Qt. So please ignore my comments in this thread.

Trusted Contributor
Posts: 160
Registered: ‎09-13-2012
My Device: 9900
My Carrier: vodafone

Re: Qt/native window - can receive screen events but not swipe down

Thanks BGmot, I've found a little more out in case anybody can help me with this. (What im trying to do is show a menu  dialog when swipe down occurs on a native screen, the swiped down screen will be qt QDialog).

 

The first swipe is now actually triggering keypressevent() and i have it now where the menu is shown over the top of the video on the first swipe.

 

However, I cannot get the swipe to continue firing after putting a QDialog over the video. I have even made a custom QDialog in case I could catch the swipe there which I couldn't.

 

I post the 2 parts of my code which are relevent because I don't think I can solve this on my own.

 

void MyWindow::keyPressEvent(QKeyEvent* qe)
{

	printf("keypressevent \n");
	fflush( stdout );

	if(qe->key() == Qt::Key_Menu)
	{
		printf("keypressswipe \n");
		fflush( stdout );
		showMenu();
		if(isShowingMenu)
		{
		int z = 1;
			screen_set_window_property_iv(externalscreen, SCREEN_PROPERTY_ZORDER, &z);

		}
		else
		{
			int z = 15;
						screen_set_window_property_iv(externalscreen, SCREEN_PROPERTY_ZORDER, &z);
		}

	}

}

void MyWindow::showMenu()
{
	printf("showmenu \n");
			fflush( stdout );
	if(swipe == NULL)
	{
		printf("showmenu is null \n");
			fflush( stdout );
		swipe = new SwipeMenu(this);
		//*swipe.setGeometry(0,0,1024, 50);
		swipe->setFixedSize(1024, 50);
		swipe->move(0,0);
		QPalette pal = swipe->palette();
		pal.setColor(QPalette::Window, Qt::white);
		swipe->setPalette(pal);
		//swipe.move(0,0);
		QPushButton* quit = new QPushButton(this);


			quit->move(10, 10);
			quit->setText(tr("disconnect"));
			quit->setMinimumSize(100, 50);
			quit->setMaximumSize(100, 50);
			//QObject::connect(pb, SIGNAL(clicked()), this,SLOT(connectClicked()));

		QVBoxLayout *swipeLayout = new QVBoxLayout;
		swipeLayout->addWidget(quit);
		swipe->setLayout(swipeLayout);
		QObject::connect(quit, SIGNAL(clicked()), this, SLOT(disconnectClicked()));
		swipe->show();

	}
	if(isShowingMenu)
	{
		isShowingMenu = false;
		printf("showing \n");
				fflush( stdout );



	}
	else
	{
		isShowingMenu= true;
		printf("hiding\n");
				fflush( stdout );


	}

	this->setFocus();
}