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
ravi1989
Posts: 777
Registered: ‎07-21-2012
My Device: 9810
My Carrier: 0
Accepted Solution

Where the display of out put. of console.log and qDebug

Hello
I am making a simple project i am using console.log in main.qml file. i am able to see the output  of console.log using this link

http://supportforums.blackberry.com/t5/Cascades-Development-Knowledge/Debug-on-the-device-with-conso...

 

and qDebug is c++ file , but i am not able to see the out on console.

I connect the device to compute and run as debug .application is launch but i am not able to see the out put of qDebug.

 

Please help me

Please use plain text.
Developer
dcharya
Posts: 74
Registered: ‎03-04-2012
My Device: developer
My Carrier: developer

Re: Where the display of out put. of console.log and qDebug

[ Edited ]

in ur main.cpp class add following code snippet 

 

void myMessageOutput(QtMsgType type, const char *msg)
 {
     //in this function, you can write the message to any stream!
     switch (type) {
     case QtDebugMsg:
         fprintf(stderr, "Debug: %s\n", msg);
         break;
     case QtWarningMsg:
         fprintf(stderr, "Warning: %s\n", msg);
         break;
     case QtCriticalMsg:
         fprintf(stderr, "Critical: %s\n", msg);
         break;
     case QtFatalMsg:
         fprintf(stderr, "Fatal: %s\n", msg);
         abort();
         break;
     }
 }

 and in main method add following line after calling constructor of Application class

i.e. Application app(argc, argv);

 

add this line :

 

 qInstallMsgHandler(myMessageOutput);

 

lemme knw if it helps you.. :smileyhappy:

Deepak Charya
Please use plain text.
Developer
ravi1989
Posts: 777
Registered: ‎07-21-2012
My Device: 9810
My Carrier: 0

Re: Where the display of out put. of console.log and qDebug

// Default empty project template
#include <bb/cascades/Application>
#include <bb/cascades/QmlDocument>
#include <bb/cascades/AbstractPane>

#include <QLocale>
#include <QTranslator>
#include <Qt/qdeclarativedebug.h>
#include "FirstApp.hpp"

using namespace bb::cascades;

void myMessageOutput(QtMsgType type, const char *msg)
 {
     //in this function, you can write the message to any stream!
     switch (type) {
     case QtDebugMsg:
         fprintf(stderr, "Debug: %s\n", msg);
         break;
     case QtWarningMsg:
         fprintf(stderr, "Warning: %s\n", msg);
         break;
     case QtCriticalMsg:
         fprintf(stderr, "Critical: %s\n", msg);
         break;
     case QtFatalMsg:
         fprintf(stderr, "Fatal: %s\n", msg);
         abort();
         break;
     }
 }

Q_DECL_EXPORT int main(int argc, char **argv)
{
    // this is where the server is started etc
    Application app(argc, argv);

    // localization support
    QTranslator translator;
    QString locale_string = QLocale().name();
    QString filename = QString( "FirstApp_%1" ).arg( locale_string );
    if (translator.load(filename, "app/native/qm")) {
        app.installTranslator( &translator );
    }
    qInstallMsgHandler(myMessageOutput);
    new FirstApp(&app);

    // we complete the transaction started in the app constructor and start the client event loop here
    return Application::exec();
    // when loop is exited the Application deletes the scene which deletes all its children (per qt rules for children)
}

 

Now my main.cpp look like this..

And // Default empty project template
#include "FirstApp.hpp"
//#include "main.cpp"
#include <bb/cascades/Application>
#include <bb/cascades/QmlDocument>
#include <bb/cascades/AbstractPane>
#include <qdebug.h>
using namespace bb::cascades;

FirstApp::FirstApp(bb::cascades::Application *app)
: QObject(app)
{
    // create scene document from main.qml asset
    // set parent to created document to ensure it exists for the whole application lifetime
    QmlDocument *qml = QmlDocument::create("asset:///main.qml").parent(this);

    // create root object for the UI
    AbstractPane *root = qml->createRootObject<AbstractPane>();
    // set created root object as a scene
    int i=0;
    qDebug()<< i;

    qDebug() << "Button Clicked - Car Year selected:";
    qDebug() << "Date:" << QDate::currentDate();
    myMessageOutput(QtDebugMsg,"Button Clicked - Car Year selected:");
    app->setScene(root);
}

 

My FirstApp.cpp look like this

 

But i am getting error in myMessageOutput' was not declared in this scope

 

Sorry i am beginner in blackberry c++ coding

Please use plain text.
Developer
ravi1989
Posts: 777
Registered: ‎07-21-2012
My Device: 9810
My Carrier: 0

Re: Where the display of out put. of console.log and qDebug

Where to see the output in console.?

Please use plain text.
Developer
dcharya
Posts: 74
Registered: ‎03-04-2012
My Device: developer
My Carrier: developer

Re: Where the display of out put. of console.log and qDebug

// Tabbed pane project template
#include "xyz.hpp"

#include <bb/cascades/Application>
#include <QLocale>
#include <QTranslator>
#include <Qt/qdeclarativedebug.h>

using namespace bb::cascades;
void myMessageOutput(QtMsgType type, const char *msg) {
	//in this function, you can write the message to any stream!
	switch (type) {
	case QtDebugMsg:
		fprintf(stderr, "Debug: %s\n", msg);
		break;
		case QtWarningMsg:
		fprintf(stderr, "Warning: %s\n", msg);
		break;
		case QtCriticalMsg:
		fprintf(stderr, "Critical: %s\n", msg);
		break;
		case QtFatalMsg:
		fprintf(stderr, "Fatal: %s\n", msg);
		abort();
		break;
	}
}
Q_DECL_EXPORT int main(int argc, char **argv) {
	// this is where the server is started etc
	Application app(argc, argv);
	qInstallMsgHandler(myMessageOutput);
	// localization support
	QTranslator translator;
	QString locale_string = QLocale().name();
	QString filename = QString("abc%1").arg(locale_string);
	if (translator.load(filename, "app/native/qm")) {
		app.installTranslator(&translator);
	}

	// create the application pane object to init UI etc.
	new xyz(&app);

	// we complete the transaction started in the app constructor and start the client event loop here
	return Application::exec();
	// when loop is exited the Application deletes the scene which deletes all its children (per qt rules for children)
}

 

Deepak Charya
Please use plain text.
Developer
ravi1989
Posts: 777
Registered: ‎07-21-2012
My Device: 9810
My Carrier: 0

Re: Where the display of out put. of console.log and qDebug

Where to see the out put , on console i am able to see only


**** Build of configuration Device-Debug for project FirstApp ****

make Device-Debug
make -C .//translations -f Makefile update
make[1]: Entering directory `C:/Documents and Settings/nksharma.Q3TECH/ndk-10.0.9-workspace/FirstApp/translations'
C:/bbndk/host_10_0_9_404/win32/x86/usr/bin/lupdate FirstApp.pro
Updating 'FirstApp.ts'...
Found 1 source text(s) (0 new and 1 already existing)
make[1]: Leaving directory `C:/Documents and Settings/nksharma.Q3TECH/ndk-10.0.9-workspace/FirstApp/translations'
make -C .//translations -f Makefile release
make[1]: Entering directory `C:/Documents and Settings/nksharma.Q3TECH/ndk-10.0.9-workspace/FirstApp/translations'
C:/bbndk/host_10_0_9_404/win32/x86/usr/bin/lrelease FirstApp.pro
The directory name is invalid.
Updating 'C:/Documents and Settings/nksharma.Q3TECH/ndk-10.0.9-workspace/FirstApp/translations/FirstApp.qm'...
Generated 0 translation(s) (0 finished and 0 unfinished)
Ignored 1 untranslated source text(s)
make[1]: Leaving directory `C:/Documents and Settings/nksharma.Q3TECH/ndk-10.0.9-workspace/FirstApp/translations'
make -C ./arm -f Makefile debug
make[1]: Entering directory `C:/Documents and Settings/nksharma.Q3TECH/ndk-10.0.9-workspace/FirstApp/arm'
make -f Makefile.Debug
make[2]: Entering directory `C:/Documents and Settings/nksharma.Q3TECH/ndk-10.0.9-workspace/FirstApp/arm'
qcc -Vgcc_ntoarmv7le -c -Wc,-include -Wc,o.le-v7-g/.obj/FirstApp -Wno-psabi -lang-c++ -fstack-protector-strong -mcpu=cortex-a9 -g -Wno-psabi -Wall -W -D_REENTRANT -DQT_NO_IMPORT_QT47_QML -DQ_OS_BLACKBERRY -DQT_DECLARATIVE_DEBUG -DQT_DECLARATIVE_LIB -DQT_CORE_LIB -DQT_SHARED -Ic:/bbndk/target_10_0_9_1673/qnx6/usr/share/qt4/mkspecs/blackberry-armv7le-qcc -I../../FirstApp -Ic:/bbndk/target_10_0_9_1673/qnx6/usr/include/qt4/QtCore -Ic:/bbndk/target_10_0_9_1673/qnx6/usr/include/qt4/QtDeclarative -Ic:/bbndk/target_10_0_9_1673/qnx6/usr/include/qt4 -I../src -Io.le-v7-g/.moc -Ic:/bbndk/target_10_0_9_1673/qnx6/usr/include -Ic:/bbndk/target_10_0_9_1673/qnx6/usr/include/freetype2 -I. -o o.le-v7-g/.obj/main.o ../src/main.cpp
qcc -Vgcc_ntoarmv7le -lang-c++ -Wl,-rpath-link,C:/bbndk/target_10_0_9_1673/qnx6/armle-v7/lib -Wl,-rpath-link,C:/bbndk/target_10_0_9_1673/qnx6/armle-v7/usr/lib -Wl,-rpath-link,C:/bbndk/target_10_0_9_1673/qnx6/armle-v7/usr/lib/qt4/lib -o o.le-v7-g/FirstApp o.le-v7-g/.obj/FirstApp.o o.le-v7-g/.obj/main.o o.le-v7-g/.obj/moc_FirstApp.o -LC:/bbndk/target_10_0_9_1673/qnx6/armle-v7/lib -LC:/bbndk/target_10_0_9_1673/qnx6/armle-v7/usr/lib -LC:/bbndk/target_10_0_9_1673/qnx6/armle-v7/usr/lib/qt4/lib -LC:/bbndk/target_10_0_9_1673/qnx6//usr/lib/qt4/lib -lbbcascades -lQtDeclarative -lQtScript -lQtSvg -lQtSql -lsqlite3 -lz -lQtXmlPatterns -lQtGui -lQtNetwork -lsocket -lQtCore -lm -lbps
make[2]: Leaving directory `C:/Documents and Settings/nksharma.Q3TECH/ndk-10.0.9-workspace/FirstApp/arm'
Could not find qmake configuration directoryCould not find qmake configuration fileUsing OS scope before setting MAKEFILE_GENERATOR
make[1]: Leaving directory `C:/Documents and Settings/nksharma.Q3TECH/ndk-10.0.9-workspace/FirstApp/arm'

**** Build Finished ****
Please use plain text.
Developer
dcharya
Posts: 74
Registered: ‎03-04-2012
My Device: developer
My Carrier: developer

Re: Where the display of out put. of console.log and qDebug

First run the application and then you wud be able to see output in console itself 

 

this is output for building process of ur application which create binaries that require to run application on device or simultor

 

if you place qDebug()<<"App Started" in ur main app u ll see this line in console

Deepak Charya
Please use plain text.
Developer
ravi1989
Posts: 777
Registered: ‎07-21-2012
My Device: 9810
My Carrier: 0

Re: Where the display of out put. of console.log and qDebug

I think there is problem in my code my application stop in 

this line without break point .

   Application app(argc, argv);

 

No source available for "(gdb[22].proc[24875225].threadGroup[i1],gdb[22].proc[24875225].OSthread[1]).thread[1].frame[0]" 

 

I think that is the reason i am not able to see anything

Please use plain text.
Developer
ravi1989
Posts: 777
Registered: ‎07-21-2012
My Device: 9810
My Carrier: 0

Re: Where the display of out put. of console.log and qDebug

Nothing is seen in console..:smileysad:

Please use plain text.
Developer
dcharya
Posts: 74
Registered: ‎03-04-2012
My Device: developer
My Carrier: developer

Re: Where the display of out put. of console.log and qDebug

its working fine at my end bro :smileyhappy:
Deepak Charya
Please use plain text.