[SOLVED]UIImagePickerController in qt
I asked this question a few days ago : "click here":http://qt-project.org/forums/viewthread/48678/
and someone suggested to me to use a qml approach.
I did and it works.
But i want to know is there another solution without qml? I don't want to use qml in my application. I want to use only cpp code in qt5.3 plus native ios code (objective c). Is there any way for that?
I want to use objective c UIImagePickerController in qt to open ios photo library and pick an image.
thanks in advance...
I already answered to your question and I didn't suggest you to use QML ... where I did ?!?!
Again, your problem on using the UIImagePickerController is that you have to get a pointer to the main root view controller of the Qt application. This is done via the gui-private headers.
In the answer of the post you cited, I write one way to get the root view controller and solve your problem.
If my solution was not suitable for your case, you should had replied in the other post, and not to open another one.
And if my solution works, then you should mark the topic as solved so other people can use it instead of open topics.
Hi Gianluca and thank. I'm sorry, you are right. But still i want to know how can i get a pointer to the main root view controller of the Qt application(cpp + objective c) via the gui-private headers? You wrote one way to get the root view controller and solve my problem but i don't want to use qml.
thank you very much
Until Qt will not made a public API to get the root view controller, your only alternative is to dig into the private headers and look for a suitable method to get the root view controller.
This is an online link to the source code: https://qt.gitorious.org/qt/qtbase/source/32c517c9906962a15f214cdcab1d57b32cc8a7e8:src/gui/kernel/qplatformnativeinterface.h
If you look to the header, you will note that there is a method called nativeResourceForBackingStore that has almost the same signature of the nativeResourceForWindow, so I suppose that works in the same way but it need a pointer to a QBackingStore.
You can get a pointer to QBackingStore from your root QWidget.
Give a try, and please mark as solved the topics if the solution works.
I finally found a way to use UIImagePickerController from qt5.3 on mac, without using qml. I created a subclass of UIViewController in .mm file and defined a method (called openiOSPhotoLibrary) in it to implement an UIImagePickerController. Then i created a cpp bridge method in the .mm file to call that method.
I'm currently on the same problem. could you maybe please post the code for the cpp bridge which starts the uiviewcontroller.
Hi, here is code:
class MainWindow : public QMainWindow
void bridgeMethodToCallObjectiveC(int , MainWindow *);
//in .mm file
void MainWindow::bridgeMethodToCallObjectiveC(int fileType , MainWindow *mainwindow)
void *context = [[photoPickerDelegate alloc] init];
[(id) context openPhotoLibraryObjC:fileType];
window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
UIImagePickerController *imageController = [[[UIImagePickerController alloc] init] autorelease];
imageController.delegate = self;
imageController.allowsEditing = NO;
imageController.mediaTypes = [[NSArray alloc] initWithObjects: (NSString *) kUTTypeMovie , nil];
[self presentViewController:imageController animated:YES completion:NULL];
thx very much :) you call the "bridgeMethodToCallObjectiveC" from your qt code!? what do you take as the window param?