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
Developer
bskania
Posts: 105
Registered: ‎04-24-2012
My Device: blackberry developer
My Carrier: relience
Accepted Solution

Is it possible to call the native playbook api from QT creator?

Hello,

 

I am currently learning developement for playbook with Qt.

For that I am using Qt creator to develope the UI specific application.

I want to know that, Is it possible to call any native api from the application that is I am making in QT creator.

As I want to integrate video and audio player in my app.

Is it easier in the native api to use both of this feature.

In QT I found it in QT mobility and with phonon but both of them are not supported on Playbook,

So please guide me with my issue.

 

Thanks in advance.

bskania.

Please use plain text.
Developer
sporadicsoftware
Posts: 72
Registered: ‎09-30-2011
My Device: Bold 9930 & PlayBook
My Carrier: Sprint

Re: Is it possible to call the native playbook api from QT creator?

Are you having a particular issue? I have only used the dialog functions and the navigator_invoke functions. Incomplete example:

 

#ifdef Q_OS_BLACKBERRY
#include <bps/dialog.h>
#endif
.
.
.

void MyWindow::openFile() {
#if defined(Q_OS_BLACKBERRY)
   dialog_instance_t alert_dialog = 0;

        bps_initialize();

        dialog_request_events(0);

        if (dialog_create_filebrowse(&alert_dialog) != BPS_SUCCESS) {
            fprintf(stderr, "Failed to create alert dialog.");
            return;
        }

        const char* Ext[1];
        Ext[0]="*.txt";

        if(dialog_set_filebrowse_filter(alert_dialog,Ext,1)!=BPS_SUCCESS) {
            fprintf(stderr, "Failed to set dialog filters.");
            dialog_destroy(alert_dialog);
            alert_dialog=0;
            return;
        }
        bool yes=false;
        if(dialog_set_filebrowse_multiselect(alert_dialog,yes)!=BPS_SUCCESS) {
            fprintf(stderr, "Failed to set dialog multiselect option.");
            dialog_destroy(alert_dialog);
            alert_dialog=0;
            return;
        }

        if (dialog_show(alert_dialog) != BPS_SUCCESS) {
            fprintf(stderr, "Failed to show alert dialog.");
            dialog_destroy(alert_dialog);
            alert_dialog = 0;
            return;
        }

        bool shutdown = false;
        char **p[100];
        while (!shutdown) {
            bps_event_t *event = NULL;
            bps_get_event(&event, -1);

            if (event) {
                if (bps_event_get_domain(event) == dialog_get_domain()) {
                    int num_paths = 1;
                    if (dialog_event_get_filebrowse_filepaths(event, p, &num_paths) != BPS_SUCCESS) {
                        return;
                    } else {
                        docPath = QString::fromUtf8(**p);
                    }
                    shutdown = true;
                }
            }
        }

        if (alert_dialog) {
            dialog_destroy(alert_dialog);
        }
        
        bps_shutdown();
}

 

Please use plain text.
Developer
bskania
Posts: 105
Registered: ‎04-24-2012
My Device: blackberry developer
My Carrier: relience

Re: Is it possible to call the native playbook api from QT creator?

Hello,

I tried the example you had given.

But its not running code part  that is written in macro Q_OS_BLACKBERRY.

I debugged the code, but its not working,

 

I am trying alot for this kind of working,

So if anyone have working examle than help me with that.

Thanks in advance

bskania,

Please use plain text.
Developer
sporadicsoftware
Posts: 72
Registered: ‎09-30-2011
My Device: Bold 9930 & PlayBook
My Carrier: Sprint

Re: Is it possible to call the native playbook api from QT creator?

If it is not running that code, you may have built Qt wrong. I did at first. What mkspec did you use? Will the code run if you change it to Q_OS_QNX?

 

Nic

Please use plain text.
Developer
bskania
Posts: 105
Registered: ‎04-24-2012
My Device: blackberry developer
My Carrier: relience

Re: Is it possible to call the native playbook api from QT creator?

I had used mkspec "blackberry-armv7le-g++" for playbook and "blackberry-x86-g++" for simulator.
Please use plain text.
Developer
bskania
Posts: 105
Registered: ‎04-24-2012
My Device: blackberry developer
My Carrier: relience

Re: Is it possible to call the native playbook api from QT creator?

No its not running if i change Q_OS_BLACKBERRY to Q_OS_QNX.
Its giving me error for the functions line fprintf().
If QT is build with default mkspec then which can be the error?
Please use plain text.
Developer
sporadicsoftware
Posts: 72
Registered: ‎09-30-2011
My Device: Bold 9930 & PlayBook
My Carrier: Sprint

Re: Is it possible to call the native playbook api from QT creator?

Was it giving you those errors with Q_OS_BLACKBERRY? If not then I would say it is at least trying to run the code now. You can just comment that out the fprintf lines. Can you post the compiler output? Did you build Qt using the instructions here: http://qt-project.org/wiki/QNX. Where and when did you get the source?

 

Nic

Please use plain text.
Developer
bskania
Posts: 105
Registered: ‎04-24-2012
My Device: blackberry developer
My Carrier: relience

Re: Is it possible to call the native playbook api from QT creator?

No instruction found on that page.
I had downloaded Qt-4_8_0-PlaybookSDK.exe from https://github.com/blackberry/Qt/downloads
and i.e before one month.
Please use plain text.
Developer
sporadicsoftware
Posts: 72
Registered: ‎09-30-2011
My Device: Bold 9930 & PlayBook
My Carrier: Sprint

Re: Is it possible to call the native playbook api from QT creator?

Sorry, drop the . at the end: http://qt-project.org/wiki/QNX

I never used the BB provided build but it is a bit old so it would make sense that you have to use Q_OS_QNX vs Q_OS_BLACKBERRY. Can you post the compiler output using Q_OS_QNX?
Please use plain text.
Developer
bskania
Posts: 105
Registered: ‎04-24-2012
My Device: blackberry developer
My Carrier: relience

Re: Is it possible to call the native playbook api from QT creator?

Hello I am getting this compier output

make: Entering directory `/Users/css/ndk-2.1.0-workspace/QTWithNDK'
rm -f moc_mainwidget.cpp
rm -f ui_mainwidget.h
rm -f main.o mainwidget.o moc_mainwidget.o
rm -f *~ core *.core
make: Leaving directory `/Users/css/ndk-2.1.0-workspace/QTWithNDK'
11:58:53: The process "/Developer/SDKs/bbndk-2.1.0-beta1/host/macosx/x86/usr/bin/make" exited normally.
11:58:53: Configuration unchanged, skipping qmake step.
11:58:53: Starting: "/Developer/SDKs/bbndk-2.1.0-beta1/host/macosx/x86/usr/bin/make" -w
make: Entering directory `/Users/css/ndk-2.1.0-workspace/QTWithNDK'
/Users/css/Qt/Qt/stage/nto/x86/usr/lib/qt4/bin/uic mainwidget.ui -o ui_mainwidget.h
qcc -Vgcc_ntox86 -lang-c++ -c -g -Wall -W -D_REENTRANT -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED -I../../Qt/Qt/stage/nto/x86/usr/lib/qt4/mkspecs/unsupported/blackberry-x86-g++ -I. -I../../Qt/Qt/stage/nto/usr/include/qt4/QtCore -I../../Qt/Qt/stage/nto/usr/include/qt4/QtGui -I../../Qt/Qt/stage/nto/usr/include/qt4 -I. -I. -I../../Qt/Qt/stage/nto/usr/include -I/Users/css/Qt/Qt/stage/nto/usr/include/freetype2 -o main.o main.cpp
qcc -Vgcc_ntox86 -lang-c++ -c -g -Wall -W -D_REENTRANT -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED -I../../Qt/Qt/stage/nto/x86/usr/lib/qt4/mkspecs/unsupported/blackberry-x86-g++ -I. -I../../Qt/Qt/stage/nto/usr/include/qt4/QtCore -I../../Qt/Qt/stage/nto/usr/include/qt4/QtGui -I../../Qt/Qt/stage/nto/usr/include/qt4 -I. -I. -I../../Qt/Qt/stage/nto/usr/include -I/Users/css/Qt/Qt/stage/nto/usr/include/freetype2 -o mainwidget.o mainwidget.cpp
/Users/css/Qt/Qt/stage/nto/x86/usr/lib/qt4/bin/moc -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED -I../../Qt/Qt/stage/nto/x86/usr/lib/qt4/mkspecs/unsupported/blackberry-x86-g++ -I. -I../../Qt/Qt/stage/nto/usr/include/qt4/QtCore -I../../Qt/Qt/stage/nto/usr/include/qt4/QtGui -I../../Qt/Qt/stage/nto/usr/include/qt4 -I. -I. -I../../Qt/Qt/stage/nto/usr/include -I/Users/css/Qt/Qt/stage/nto/usr/include/freetype2 -D__QNXNTO__ mainwidget.h -o moc_mainwidget.cpp
qcc -Vgcc_ntox86 -lang-c++ -c -g -Wall -W -D_REENTRANT -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED -I../../Qt/Qt/stage/nto/x86/usr/lib/qt4/mkspecs/unsupported/blackberry-x86-g++ -I. -I../../Qt/Qt/stage/nto/usr/include/qt4/QtCore -I../../Qt/Qt/stage/nto/usr/include/qt4/QtGui -I../../Qt/Qt/stage/nto/usr/include/qt4 -I. -I. -I../../Qt/Qt/stage/nto/usr/include -I/Users/css/Qt/Qt/stage/nto/usr/include/freetype2 -o moc_mainwidget.o moc_mainwidget.cpp
qcc -Vgcc_ntox86 -lang-c++ -Wl,-rpath-link,/Users/css/Qt/Qt/stage/nto/x86/lib -Wl,-rpath-link,/Users/css/Qt/Qt/stage/nto/x86/usr/lib -o QTWithNDK main.o mainwidget.o moc_mainwidget.o -L/Users/css/Qt/Qt/stage/nto/x86/lib -L/Users/css/Qt/Qt/stage/nto/x86/usr/lib -L/Users/css/Qt/Qt/stage/nto/x86/usr/lib/qt4/lib -lQtGui -L/Users/css/Qt/Qt/stage/nto/x86/usr/lib/qt4/lib -L/Users/css/Qt/Qt/stage/nto/x86/lib -L/Users/css/Qt/Qt/stage/nto/x86/usr/lib -lQtCore -lm
mainwidget.o: In function `MainWidget::smileysurprised:penFile()':
/Users/css/ndk-2.1.0-workspace/QTWithNDK/mainwidget.cpp:30: undefined reference to `bps_initialize'
/Users/css/ndk-2.1.0-workspace/QTWithNDK/mainwidget.cpp:32: undefined reference to `dialog_request_events'
/Users/css/ndk-2.1.0-workspace/QTWithNDK/mainwidget.cpp:34: undefined reference to `dialog_create_filebrowse'
/Users/css/ndk-2.1.0-workspace/QTWithNDK/mainwidget.cpp:42: undefined reference to `dialog_set_filebrowse_filter'
/Users/css/ndk-2.1.0-workspace/QTWithNDK/mainwidget.cpp:44: undefined reference to `dialog_destroy'
/Users/css/ndk-2.1.0-workspace/QTWithNDK/mainwidget.cpp:49: undefined reference to `dialog_set_filebrowse_multiselect'
/Users/css/ndk-2.1.0-workspace/QTWithNDK/mainwidget.cpp:51: undefined reference to `dialog_destroy'
/Users/css/ndk-2.1.0-workspace/QTWithNDK/mainwidget.cpp:56: undefined reference to `dialog_show'
/Users/css/ndk-2.1.0-workspace/QTWithNDK/mainwidget.cpp:58: undefined reference to `dialog_destroy'
/Users/css/ndk-2.1.0-workspace/QTWithNDK/mainwidget.cpp:67: undefined reference to `bps_get_event'
/Users/css/ndk-2.1.0-workspace/QTWithNDK/mainwidget.cpp:70: undefined reference to `bps_event_get_domain'
/Users/css/ndk-2.1.0-workspace/QTWithNDK/mainwidget.cpp:70: undefined reference to `dialog_get_domain'
/Users/css/ndk-2.1.0-workspace/QTWithNDK/mainwidget.cpp:72: undefined reference to `dialog_event_get_filebrowse_filepaths'
/Users/css/ndk-2.1.0-workspace/QTWithNDK/mainwidget.cpp:83: undefined reference to `dialog_destroy'
/Users/css/ndk-2.1.0-workspace/QTWithNDK/mainwidget.cpp:86: undefined reference to `bps_shutdown'
cc: /Developer/SDKs/bbndk-2.1.0-beta1/host/macosx/x86/usr/bin/ntox86-ld error 1
make: *** [QTWithNDK] Error 1
make: Leaving directory `/Users/css/ndk-2.1.0-workspace/QTWithNDK'
11:58:55: The process "/Developer/SDKs/bbndk-2.1.0-beta1/host/macosx/x86/usr/bin/make" exited with code 2.
Error while building/deploying project QTWithNDK (target: QNX x86)
When executing step 'Make'

I had used .pro file in which included path

BB_NDK = /Developer/SDKs/bbndk-2.1.0-beta1
INCLUDEPATH += $$BB_NDK/target/qnx6/usr/include
LIBS += -lbps

bskania.
Please use plain text.