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

Swapping z-order of screens

[ Edited ]

Hi all,

 

I have a native window (video) and i have a qt window which is the parent. I want to swap these around in order to show a menu when swipe down occurs and video is playing.

 

The menu has to be on the qt window for buttons and I cant create another (third window in group) qt screen for menu (to do with catching swipe events) so i just redo setCentrelWidget() for my only qt window to show menu stuff instaed of main qt stuff.

 

When I play video the z_order works good, the video appears and I can capture screen touch events as I have set native to z = 2 and I set z=1 for qt window.

 

When I swipe down - all is good as well, the menu shows/hides.

 

However, my problem for days has been that when I stop/disconnect the video and then play it again the native video window doesn't appear of it's own accord (only when i swipe down) this time if even though the same connect/play (native z = 2, qt z = 1) function is called, also I then can't capture my screen events anymore.

 

The main code is below..

 

void MyWindow::showMenu()
{
	printf("showmenu \n");
	fflush( stdout );
	
	
		printf("showmenu is null \n");
		fflush( stdout );
		
		//*swipe.setGeometry(0,0,1024, 50);
		setFixedSize(1024, 50);
		move(0,0);
		QPalette pal = palette();
		pal.setColor(QPalette::Window, Qt::white);
		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();
		setCentralWidget(new QWidget);
		centralWidget()->setLayout(swipeLayout);

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



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


	}

	this->setFocus();
}


void MyWindow::keyPressEvent(QKeyEvent* qe)//'	moc_mywindow.cpp	/ControlYourPC/src	 	C/C++ Problem
{

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

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

			if(thisWindow == NULL)
			{
				thisWindow = (screen_window_t)winId();
			}

			screen_set_window_property_iv(externalscreen, SCREEN_PROPERTY_ZORDER, &z);
			z = 2;
			screen_set_window_property_iv(thisWindow, SCREEN_PROPERTY_ZORDER, &z);

		}
		else
		{
			int z = 1;

			if(thisWindow == NULL)
			{
				thisWindow = (screen_window_t)winId();
			}
			screen_set_window_property_iv(thisWindow, SCREEN_PROPERTY_ZORDER, &z);

			z = 2;
			screen_set_window_property_iv(externalscreen, SCREEN_PROPERTY_ZORDER, &z);

		}

	}

}

void  MyWindow::connectClicked()
{


	
	this->connected = true;	
	if(thisWindow == NULL)
	{
		thisWindow = (screen_window_t)winId();
	}
	int z = 1;
	screen_set_window_property_iv(thisWindow, SCREEN_PROPERTY_ZORDER, &z);
	z = 2;
	screen_set_window_property_iv(externalscreen, SCREEN_PROPERTY_ZORDER, &z);
	hide();
	*instructionbuffer = (char*)malloc( sizeof(char)* 600);
	this->connected = true;
	createThread();
	createKeyboardThread();

}

void MyWindow::disconnectClicked()
{
	printf("disconnectclicked \n");
	fflush( stdout );
	isShowingMenu = false;
	connected=false;
	int z = 1;
	screen_set_window_property_iv(externalscreen, SCREEN_PROPERTY_ZORDER, &z);
	initMainScreen();


	if(thisWindow == NULL)
	{
		thisWindow = (screen_window_t)winId();
	}

	z = 2;
	screen_set_window_property_iv(thisWindow, SCREEN_PROPERTY_ZORDER, &z);

}

 Any help appreciated - I just need my app to work the fsecond same as it does the first time connectclicked  is called.