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

Re: Problem/Questions - QT

forgot to mention BGmot, I only started to follow that guide from the following steps which really helped.

 

2. Create QTHelloWorld project in Momentics IDE

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

Re: Problem/Questions - QT

Ok, then it makes sense.

You slightly misunderstood me. I don't want you to go back to QtCreator I just want you to try to use Creator's libraries and includes. So basically proceed with Momemntics but replace everything here

<asset path="C:/QtPlaybookSDK/Playbook/Qt/4.8.1/lib/libQtOpenGL.so.4.8.1" type="Qnx/Elf">lib/libQtOpenGL.so.4</asset>
<asset path="C:/QtPlaybookSDK/Playbook/Qt/4.8.1/lib/libQtCore.so.4.8.1" type="Qnx/Elf">lib/libQtCore.so.4</asset>
<asset path="C:/QtPlaybookSDK/Playbook/Qt/4.8.1/lib/libQtGui.so.4.8.1" type="Qnx/Elf">lib/libQtGui.so.4</asset>
 
"C:\QtPlaybookSDK\Playbook\Qt\4.8.1\include\Qt" "C:\QtPlaybookSDK\Playbook\Qt\4.8.1\include\QtCore"
"C:\QtPlaybookSDK\Playbook\Qt\4.8.1\include\QtGui"

 

with the same but from QtCreator's folders. And then use moc.exe that should be somewhere in QtCreator's folders. This way you'll be consistent.

Otherwise sorry I don't have more ideas... though today does not look to be 'my day' so probably somebody else will give you better advice. -)

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

Re: Problem/Questions - QT

The download that contains the binaries extracts into 3 folders 

 

C:\QtPlaybookSDK\vcredist_x86

C:\QtPlaybookSDK\QtCreator

C:\QtPlaybookSDK\Playbook*

 

with the third folder* being where moc.exe and the actual .so files for qt are stored, this is where i am getting my moc.exe from earlier example and my qtcore.so etc. Neither of the other 2 folders contains moc or any .so files.

 

Could it be that the files are out of date provided in this download? I'm have vague memory of reading something about overwriting one version of files with another but wouldnt know where to begin looking for this comment now.

 

 

 

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

Re: Problem/Questions - QT

I don't have Windows box but my Mac version of QtCreator has its own moc utility.

By the way if your QtCreator works ok and you create a project with the same source files as you have not in Momentics it will create moc_xxx.cpp files for you automatically.

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

Re: Problem/Questions - QT

BGmot (and anyone else who can help), I decided to leave it last night and when I came back to it this morning  my .h had just become blank. woops. I don't know if I did this with moc.exe last night.

 

After more hours I now have the QObject stuff back in one file and the rest of the network /ffmpeg code in other classes/threads. So it must be working again because I don't access the QT code in more than file. Is that appropriate anyway to have it this way? (I won't even begin to implement ffmpeg frames into qt ui now until tonight so cant check right now).

 

I think I did notice you were referencing ndk 10 moc when i had a scan through this thread again - is that relevent to my earlier problem when trying to run moc on my files and I was getting the error?

 

Thanks for your time.

 

C

 

 

 

 

Developer
Posts: 1,041
Registered: ‎07-16-2008
My Device: ಠ_ಠ

Re: Problem/Questions - QT

[ Edited ]

I only skimmed the replies... but if you're using QT now you should be using the makefile/PRO file approach. It will handle moc for you. Check out the cascade sample projects (or the FFCameraSample). You're probably better off just starting from one of them and deleting the parts you don't need.

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

Re: Problem/Questions - QT

[ Edited ]

thanks mreed for your info.

 

I went down that path after reading your post and ended up not being able to link the libraries correctly qt and ffmpeg. I created a makefile c++ empty project and I wasnt given a .pro file like in camera sample, there was a common.mk and makefile instaed. I spent a few hours on it. I added the following to the comon.mk. Still doesn't work - cannot resolve includes for my qt and ffmpeg libs. What is the correct way to link to the lib, includes and the the actual -lavcodec for e.g in makefile?

 

EXTRA_INCVPATH+=$(QNX_TARGET)/usr/include/freetype2 \
$(QNX_TARGET)/../target-override/usr/include \
C:\QtPlaybookSDK\Playbook\Qt\4.8.1\include\QtCore \
C:\QtPlaybookSDK\Playbook\Qt\4.8.1\include\QtOpenGL \
C:\QtPlaybookSDK\Playbook\Qt\4.8.1\include\QtGui \
C:\ndk-2.1.0-workspace\test3\ffmpeg\include\avcodec \
C:\ndk-2.1.0-workspace\test3\ffmpeg\include\avformat \
C:\ndk-2.1.0-workspace\test3\ffmpeg\include\avutil \
C:\ndk-2.1.0-workspace\test3\ffmpeg\include

# Extra library search path for target overrides and patches
EXTRA_LIBVPATH+=$(QNX_TARGET)/../target-override/$(CPUVARDIR)/lib \
$(QNX_TARGET)/../target-override/$(CPUVARDIR)/usr/lib \
C:/QtPlaybookSDK/Playbook/Qt/4.8.1/lib \

C:/ndk-2.1.0-workspace/test3/ffmpeg/lib

 

And with regards to moc well another day has been wasted without any coding being done - so frustrating.

 

I can get a moc output file in my src but it contains

 

#if !defined(Q_MOC_OUTPUT_REVISION)
#error "The header file 'mywindow.h' doesn't include <QObject>."
#elif Q_MOC_OUTPUT_REVISION != 63
#error "This file was generated using the moc from 4.8.0. It"
#error "cannot be used with the include files from this version of Qt."
#error "(The moc has changed too much.)"
#endif

 

I have tried to do this process with the playbookqtsdk moc file and the ndk 10 moc file, both show errors like that but 4.8.0 for pbqtsdk and 4.8.2 when i try with the moc from ndk 10.

Developer
Posts: 1,041
Registered: ‎07-16-2008
My Device: ಠ_ಠ

Re: Problem/Questions - QT

[ Edited ]

Edit Note: I just noticed you're using PlayBook and not BB10/Cascades. I'm not sure how thats supported. The comment below is for Cascades and configs that are included in the BB10 NDK. Mah baad.

 


 

Yea, it doesn't create the PRO file. It's really stupid confusing and I also spent hours figuring this all out. Thats why you should just copy a sample and edit it, or at the vary least compare yours and actually see how its different. (The makefile when using a PRO is going to be different.) FFCameraSample has both QT and linking to the FFmpeg libs in the PRO file. You don't need to add all those includes.

 

CONFIG += qt warn_on debug_and_release cascades

 

Stop avoiding the samples. They're good for you.

 

https://github.com/hardisonbrewing/FFCameraSample

https://github.com/hardisonbrewing/FFCameraSample/blob/master/Makefile

https://github.com/hardisonbrewing/FFCameraSample/blob/master/FFCameraSample.pro

 

Just note that the PRI references are something I added to my sample... its not in the other Cascades samples. They all just use wildcards to include the headers and source files.

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

Re: Problem/Questions - QT

I hear you on the samples, I looked through them earlier today and i think that was the confusion = bb10.

 

I have spent last 24 hours trying to overcome the moc issue and eventually installing full version of qt fixed it. I still get an error in the header of the moc file but it builds ok and the error i was getting when trying to build before installing qt (x11event) has gone.

 

During the day I was trying to answer another question as well - how can i create an QApplication/QWidget in main.cpp and then have my other classes write to this display ? 

 

if i add my network code in constructor of my other .cpp then the screen never shows because the constructor doesn't return but network code runs.

 

If I try to have the following in main.cpp and no network code in the constructor of mywindow.cpp but in mywindow.main2() instead then the red screen shows ok but mywindow.main2() doesn't get called - but no error.

 

int main(int argc, char *argv[])
{
	cout << "main";
	cout.flush();
	QCoreApplication::addLibraryPath("app/native/lib");

	QApplication app(argc, argv);

	mywindow window;

	window.resize(1024, 600);
	QPalette pal = window.palette();
	pal.setColor(QPalette::Window, Qt::red);
	window.setPalette(pal);
	QPushButton quit("Quit", &window);
	quit.setGeometry(422, 100, 180, 40);
	QObject::connect(&quit, SIGNAL(clicked()), &app, SLOT(quit()));

	window.show();


	int i = app.exec();// a.exec();
	pthread_create(&notuiThread, 0, &runnotuiThread, &window);
	return i;
}

 

void* runnotuiThread(void* arg)
{
	cout << "notonuithreaad";
	cout.flush();
	reinterpret_cast<mywindow*>(&arg)->main2();


}

 

 

I know it's probably one for another thread but i am drained for now so its one for morning if no hints by then.

 

I really appreciate how far you guys are bringing me along in recent weeks, thanks again.

Contributor
Posts: 41
Registered: ‎09-14-2012
My Device: Playbook 64Gb
My Carrier: n/a

Re: Problem/Questions - QT

app.exec() is the main event loop -- it won't return until the user does something that causes the event loop to terminate. So it looks like your new thread won't start until an instant before the application exits Smiley Happy

 

Try starting your thread earlier; but you'll have to find a way to synchronize it to the UI so that it doesn't try to output to UI elements that don't exist. This isn't really a Qt problem -- it's a standard problem of multi-threaded programming. You could try creating your thread at the end of the constructor of your main widget -- that should ensure that all the long-lived UI elements have been instantiated. It doesn't necessarily mean they are visible on screen, however -- that's a matter of implementation details.

 

My experience with Qt and Gtk has been that it's better to try to avoid updating a UI in a different thread than the one that created the UI elements. It is do-able, and the framework does provide thread-safe ways to do it, but it's a real pain in the backside a lot of the time. Of course, sometimes there is no alternative.

 

There's an example:

 

http://doc.qt.digia.com/latest/network-blockingfortuneclient.html

 

that shows how network operations can be done in a thread-safe way and still update the UI.