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
Posts: 41
Registered: ‎09-14-2012
My Device: Playbook 64Gb
My Carrier: n/a

Re: How can I create a ui with my code for 2.1

If it's a question of building Qt, I could supply the binaries that I use. They're just a bunch of .so files. Too big to go in an email, but I'm sure there's another way. I use the standard qmake utility to make a Makefile that links my app with libraries. I'm working on Linux -- I know how to do Qt for BB under Linux, but I don't have a clue how to do this on Windows.

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

Re: How can I create a ui with my code for 2.1

Thanks for the offer kboone, I eventually found an exe which extracts the whole of qt binaries and qt creator which i think is even specific for blackberry. One thing to note about this exe - it doesn't like it if you have the qnx sdk in the PATH variable. Won't install.

 

I have eventually got qt running by including a limited amount of the qt .so files in momentics and am now embarking on creating a qt ui and then linking the ui to the code which paints the video frames from ffmpeg stream .

 

More fun ahead!

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

Re: How can I create a ui with my code for 2.1

Sorry to dig this up again but I'm still struggling after 3 more days to intergrate Qt and screen.h to have textbox, button and videoframes (just blitting) on my playbook screen and i'm hoping somebody can clarify if this is even possible and if it is then what am i doing wrong - i have simplified it down to about 15 lines of code which initialises a QMainWindow and then creates a screen with what i hope is a higher z order and also trys to join the window group - QMainWindow.winId. 

 

All I see is my red square in the corner - my QMainWindow with a dimensions of 100 x 100 and pallette of red.

 

The rest of the screen is just plain black.

 

It must be to do with linking the screen.h i create with the proper window group which qt has joined but how this is done is a mystery.

 

int main(int argc, char *argv[])
{


	cout << "main ";
	cout.flush();
	QCoreApplication::addLibraryPath("app/native/lib");

	QApplication app(argc, argv);

	mywindow window;

	window.resize(500, 500);
	QPalette pal = window.palette();
	pal.setColor(QPalette::Window, Qt::red);
	window.setPalette(pal);


	window.show();
	cout << "main wid is " << window.winId();
		cout.flush();

		const int usage = SCREEN_USAGE_NATIVE;
		int i = app.exec();
		    screen_context_t screen_ctx;
		    screen_window_t screen_win;
		    screen_buffer_t screen_buf = NULL;
		    int rect[4] = { 0, 0, 0, 0};

		    /* Setup the window */
		    screen_create_context(&screen_ctx, 0);
		    screen_create_window_type(&screen_win, screen_ctx, SCREEN_CHILD_WINDOW);
			char* idArr = "HelloForeignWindowAppID";
			
			const char* cc = ""+window.winId();
			screen_join_window_group(screen_win, cc);
			screen_set_window_property_cv(screen_win, SCREEN_PROPERTY_ID_STRING, sizeof(idArr), idArr);
			cout << "after join window ";
			cout.flush();
		    screen_set_window_property_iv(screen_win, SCREEN_PROPERTY_USAGE, &usage);
		    screen_create_window_buffers(screen_win, 1);
		    int pos[] = { 100, 100 };
		    screen_set_window_property_iv(screen_win, SCREEN_PROPERTY_POSITION, pos);
		    screen_get_window_property_pv(screen_win, SCREEN_PROPERTY_RENDER_BUFFERS, (void **)&screen_buf);
		    screen_get_window_property_iv(screen_win, SCREEN_PROPERTY_BUFFER_SIZE, rect+2);
		    int visible = 10;
		   //	screen_set_window_property_iv(screen_win, SCREEN_PROPERTY_VISIBLE, &visible);
		   	screen_set_window_property_iv(screen_win, SCREEN_PROPERTY_ZORDER, &visible);
		    /* Fill the screen buffer with blue */
		    int attribs[] = { SCREEN_BLIT_COLOR, 0xffffffff, SCREEN_BLIT_END };
		    screen_fill(screen_ctx, screen_buf, attribs);
		    screen_post_window(screen_win, screen_buf, 1, rect, 0);

		    /* Signal bps library that navigator and screen events will be requested */
		    //bps_initialize();
		    //screen_request_events(screen_ctx);
		    //navigator_request_events(0);
		    //pthread_create(&notuiThread, 0, &runnotuiThread, &window);

		    return i;
}

 

BlackBerry Development Advisor
Posts: 683
Registered: ‎11-29-2011
My Device: PRIV
My Carrier: Rogers

Re: How can I create a ui with my code for 2.1

Some comments....

1. what's a "mywindow"?  I don't see that class defined. Is it a ForeignWindowControl or something from Qt?

2. windows join window groups, not window ids, so I think what you're trying to do will only work if the parent window id = parent window group.  you will need to find a way to query the SCREEN_PROPERTY_GROUP of Qt's application window. 

3. child windows don't become visible until after the parent window is made visible, flushed, etc.  If by some coincidence the strings match up in #2, it's possible that the application window context just needs to be flushed, but I don't know what would force Qt to do that.

4. you commented out setting SCREEN_PROPERTY_VISIBLE.  I can't recall whether the default is invisible or visible.

5. Where is your error checking?  Are any of these commands failing?

 

Cheers,

Sean

BlackBerry Development Advisor
Posts: 683
Registered: ‎11-29-2011
My Device: PRIV
My Carrier: Rogers

Re: How can I create a ui with my code for 2.1

Another interesting note.. you can use screen_get_context_property_pv() to retrieve SCREEN_PROPERTY_WINDOWS, which is the complete list of windows for the context. (SCREEN_PROPERTY_WINDOW_COUNT is the number of windows in the context)

Unfortunately, you would need to get a hold of Qt's screen_context_t, not the one you are creating.  Again, I'm not sure what Qt exposes.

 

Cheers,

Sean

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

Re: How can I create a ui with my code for 2.1

Hi Sean, thanks for your reply.

 

mywindow is a class i created and extends QMainWindow. It does nothing currently other than output to console in constructor.

 

Regarding error messages, this is very basic code from a screen template app and I wasn't getting any errors with my proper code neither - i have had to rewrite this or just paste the simialr code many times to make sure im not wrong. I strongly believe my code isn't wrong now and what you mention (you would need to get a hold of Qt's screen_context_t) is exactly what my problem is. Unless we can know more about the window created for qt then how can i add my window to it?

 

But I went down this path because it was made out to be possible just like in ForeignWindow/Cascades but maybe now I'm not too sure it is possible.

BlackBerry Development Advisor
Posts: 683
Registered: ‎11-29-2011
My Device: PRIV
My Carrier: Rogers

Re: How can I create a ui with my code for 2.1

Cascades' ForeignWindowControl exposes the window group, which is why it works.  If Qt doesn't, then you are probably out of luck.  The good news of course is that the source for Qt is available, so you could rebuild it with a ::winGroup() member alongside ::winId().

BlackBerry Development Advisor
Posts: 683
Registered: ‎11-29-2011
My Device: PRIV
My Carrier: Rogers

Re: How can I create a ui with my code for 2.1

also.. are you sure QWindow::winId() even returns the same string that is used by the underlying screen window?  you would have to check out the source.

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

Re: How can I create a ui with my code for 2.1

The thought of rebuilding qt turns my stomach, i think i spent a day trying to build and then found an .exe which also contained qt creator and thats where i got the binaries from.

 

The one thing that gives me hope is the following thread which I think awx states he managed to do what im trying but Ive been trying to follow what he says since last night.

 

"What does work is if I just get the winId() and join that window to a group, then I can join a non Qt window to the same group. However I was under the impression that Qt was already adding the window to a group and that its best to use that same group".

 

http://supportforums.blackberry.com/t5/Native-Development/Is-it-possible-to-get-the-screen-window-gr...

 

p.s all rc are equal to 0 in that main function.

Highlighted
Contributor
Posts: 24
Registered: ‎09-10-2012
My Device: Blackberry Dev Alpha
My Carrier: -

Re: How can I create a ui with my code for 2.1


smcveigh wrote:

also.. are you sure QWindow::winId() even returns the same string that is used by the underlying screen window?  you would have to check out the source.


This is how winId() is implemented right now:

WId winId() const { return (WId)m_window; }

 

Where m_window is of type screen_window_t. But that is an implementation detail, it is quite dangerous to rely on that.

For getting the window group, Qt provides a hook for that, in the QPlatformNativeInterface class. Example of its usage:

Qt4:

QPlatformNativeInterface * const nativeInterface = QApplication::platformNativeInterface();
const char * const groupNameData = static_cast<const char *>(
        nativeInterface->nativeResourceForWidget("windowGroup", widget));
const QString groupName = QString::fromAscii(groupNameData);

('widget' is of type QWidget and needs to be the toplevel one)

Qt5:

QPlatformNativeInterface * const nativeInterface = QGuiApplication::platformNativeInterface();
const char * const groupNameData = static_cast<const char *>(
        nativeInterface->nativeResourceForWindow("windowGroup", window));
const QString groupName = QString::fromLatin1(groupNameData);

('window' is of type QWindow)