c++ - Qt Android qApp->primaryScreen()->availableGeometry() return 0x0 -
when use qapp->primaryscreen()->availablegeometry();
in application if use on desktop (either linux or windows) size of available screen , important me because size of each element of application calculated depending on height , width available on screen, when running on adv returns 0x0 prevents correct application functionality. if try deploy in physical device, debugger , application not begin. in full log this:
debugging starts d/dalvikvm( 4630): not late-enabling checkjni (already on) i/dalvikvm( 4630): zip good, no classes.dex inside, , no valid .odex file in same directory i/dalvikvm( 4630): zip good, no classes.dex inside, , no valid .odex file in same directory i/dalvikvm( 4630): zip good, no classes.dex inside, , no valid .odex file in same directory i/dalvikvm( 4630): zip good, no classes.dex inside, , no valid .odex file in same directory d/dalvikvm( 4630): trying load lib /data/local/tmp/qt/lib/libgnustl_shared.so 0xb2d01db8 d/dalvikvm( 4630): added shared lib /data/local/tmp/qt/lib/libgnustl_shared.so 0xb2d01db8 d/dalvikvm( 4630): no jni_onload found in /data/local/tmp/qt/lib/libgnustl_shared.so 0xb2d01db8, skipping init d/dalvikvm( 4630): trying load lib /data/local/tmp/qt/lib/libqt5core.so 0xb2d01db8 d/dalvikvm( 4630): added shared lib /data/local/tmp/qt/lib/libqt5core.so 0xb2d01db8 d/dalvikvm( 4630): trying load lib /data/local/tmp/qt/lib/libqt5gui.so 0xb2d01db8 d/dalvikvm( 4630): added shared lib /data/local/tmp/qt/lib/libqt5gui.so 0xb2d01db8 d/dalvikvm( 4630): no jni_onload found in /data/local/tmp/qt/lib/libqt5gui.so 0xb2d01db8, skipping init d/dalvikvm( 4630): trying load lib /data/local/tmp/qt/lib/libqt5network.so 0xb2d01db8 d/dalvikvm( 4630): added shared lib /data/local/tmp/qt/lib/libqt5network.so 0xb2d01db8 d/dalvikvm( 4630): no jni_onload found in /data/local/tmp/qt/lib/libqt5network.so 0xb2d01db8, skipping init d/dalvikvm( 4630): trying load lib /data/local/tmp/qt/lib/libqt5qml.so 0xb2d01db8 d/dalvikvm( 4630): added shared lib /data/local/tmp/qt/lib/libqt5qml.so 0xb2d01db8 d/dalvikvm( 4630): no jni_onload found in /data/local/tmp/qt/lib/libqt5qml.so 0xb2d01db8, skipping init d/dalvikvm( 4630): trying load lib /data/local/tmp/qt/lib/libqt5quick.so 0xb2d01db8 d/dalvikvm( 4630): added shared lib /data/local/tmp/qt/lib/libqt5quick.so 0xb2d01db8 d/dalvikvm( 4630): no jni_onload found in /data/local/tmp/qt/lib/libqt5quick.so 0xb2d01db8, skipping init d/dalvikvm( 4630): trying load lib /data/local/tmp/qt/lib/libqt5widgets.so 0xb2d01db8 d/dalvikvm( 4630): added shared lib /data/local/tmp/qt/lib/libqt5widgets.so 0xb2d01db8 d/dalvikvm( 4630): no jni_onload found in /data/local/tmp/qt/lib/libqt5widgets.so 0xb2d01db8, skipping init d/dalvikvm( 4630): trying load lib /data/local/tmp/qt/lib/libqt5sql.so 0xb2d01db8 d/dalvikvm( 4630): added shared lib /data/local/tmp/qt/lib/libqt5sql.so 0xb2d01db8 d/dalvikvm( 4630): no jni_onload found in /data/local/tmp/qt/lib/libqt5sql.so 0xb2d01db8, skipping init d/dalvikvm( 4630): trying load lib /data/local/tmp/qt/lib/libqt5positioning.so 0xb2d01db8 d/dalvikvm( 4630): added shared lib /data/local/tmp/qt/lib/libqt5positioning.so 0xb2d01db8 d/dalvikvm( 4630): no jni_onload found in /data/local/tmp/qt/lib/libqt5positioning.so 0xb2d01db8, skipping init d/dalvikvm( 4630): trying load lib /data/local/tmp/qt/lib/libqt5quickparticles.so 0xb2d01db8 d/dalvikvm( 4630): added shared lib /data/local/tmp/qt/lib/libqt5quickparticles.so 0xb2d01db8 d/dalvikvm( 4630): no jni_onload found in /data/local/tmp/qt/lib/libqt5quickparticles.so 0xb2d01db8, skipping init d/dalvikvm( 4630): trying load lib /data/local/tmp/qt/plugins/platforms/android/libqtforandroid.so 0xb2d01db8 d/dalvikvm( 4630): added shared lib /data/local/tmp/qt/plugins/platforms/android/libqtforandroid.so 0xb2d01db8 i/qt ( 4630): qt start d/dalvikvm( 4630): trying load lib /data/local/tmp/qt/plugins/bearer/libqandroidbearer.so 0xb2d01db8 d/dalvikvm( 4630): added shared lib /data/local/tmp/qt/plugins/bearer/libqandroidbearer.so 0xb2d01db8 d/dalvikvm( 4630): no jni_onload found in /data/local/tmp/qt/plugins/bearer/libqandroidbearer.so 0xb2d01db8, skipping init d/dalvikvm( 4630): trying load lib /data/local/tmp/qt/lib/libqt5quickparticles.so 0xb2d01db8 d/dalvikvm( 4630): shared lib '/data/local/tmp/qt/lib/libqt5quickparticles.so' loaded in same cl 0xb2d01db8 d/dalvikvm( 4630): trying load lib /data/local/tmp/qt/plugins/position/libqtposition_android.so 0xb2d01db8 d/dalvikvm( 4630): added shared lib /data/local/tmp/qt/plugins/position/libqtposition_android.so 0xb2d01db8 i/qtpositioning( 4630): positioning start d/dalvikvm( 4630): gc_concurrent freed 189k, 9% free 2918k/3184k, paused 27ms+24ms, total 266ms d/dalvikvm( 4630): trying load lib /data/app-lib/org.qtproject.example.appturista-1/libappturista.so 0xb2cda5c8 d/ ( 4630): (null):0 ((null)): qml debugging enabled. use in safe environment. d/dalvikvm( 4630): added shared lib /data/app-lib/org.qtproject.example.appturista-1/libappturista.so 0xb2cda5c8 d/dalvikvm( 4630): no jni_onload found in /data/app-lib/org.qtproject.example.appturista-1/libappturista.so 0xb2cda5c8, skipping init i/qt java ( 4630): debugger: parameters: bundle[{debug_ping=true, gdbserver_socket=/data/data/org.qtproject.example.appturista/debug-socket, qml_debug=true, gdbserver_command=/data/data/org.qtproject.example.appturista/lib/libgdbserver.so --multi +/data/data/org.qtproject.example.appturista/debug-socket, qmljsdebugger=port:55091,block, ping_socket=org.qtproject.example.appturista.ping_pong_socket}] i/qt java ( 4630): debugger: removing gdb socket /data/data/org.qtproject.example.appturista/debug-socket i/qt java ( 4630): debugger: starting /data/data/org.qtproject.example.appturista/lib/libgdbserver.so --multi +/data/data/org.qtproject.example.appturista/debug-socket i/qt java ( 4630): debugger: gdbserver started i/qt java ( 4630): debugger: waiting socket @ /data/data/org.qtproject.example.appturista/debug-socket, attempt 0 i/qt java ( 4630): debugger: waiting socket @ /data/data/org.qtproject.example.appturista/debug-socket, attempt 1 i/qt java ( 4630): debugger: socket ok i/qt java ( 4630): debugger: waiting debug socket connect i/qt java ( 4630): debugger: go sleep i/qt java ( 4630): debugger: waiting debug socket connect i/qt java ( 4630): debugger: go sleep i/qt java ( 4630): debugger: debug socket accepted i/qt java ( 4630): debugger: waiting debug socket connect i/qt java ( 4630): debugger: go sleep i/qt java ( 4630): debugger: waiting debug socket connect i/qt java ( 4630): debugger: go sleep i/qt java ( 4630): debugger: waiting debug socket connect i/qt java ( 4630): debugger: go sleep i/qt java ( 4630): debugger: waiting debug socket connect i/qt java ( 4630): debugger: go sleep i/qt java ( 4630): debugger: waiting debug socket connect i/qt java ( 4630): debugger: go sleep i/qt java ( 4630): debugger: waiting debug socket connect i/qt java ( 4630): debugger: go sleep i/qt java ( 4630): debugger: waiting debug socket connect i/qt java ( 4630): debugger: go sleep i/qt java ( 4630): debugger: waiting debug socket connect i/qt java ( 4630): debugger: go sleep i/qt java ( 4630): debugger: waiting debug socket connect i/qt java ( 4630): debugger: go sleep i/qt java ( 4630): debugger: waiting debug socket connect i/qt java ( 4630): debugger: go sleep i/qt java ( 4630): debugger: waiting debug socket connect i/qt java ( 4630): debugger: go sleep i/qt java ( 4630): debugger: waiting debug socket connect i/qt java ( 4630): debugger: go sleep i/qt java ( 4630): debugger: waiting debug socket connect i/qt java ( 4630): debugger: go sleep i/qt java ( 4630): debugger: waiting debug socket connect i/qt java ( 4630): debugger: go sleep i/qt java ( 4630): debugger: waiting debug socket connect i/qt java ( 4630): debugger: go sleep i/qt java ( 4630): debugger: waiting debug socket connect i/qt java ( 4630): debugger: go sleep i/qt java ( 4630): debugger: waiting debug socket connect i/qt java ( 4630): debugger: go sleep i/qt java ( 4630): debugger: waiting debug socket connect i/qt java ( 4630): debugger: go sleep i/qt java ( 4630): debugger: waiting debug socket connect i/qt java ( 4630): debugger: go sleep i/qt java ( 4630): debugger: waiting debug socket connect i/qt java ( 4630): debugger: go sleep i/qt java ( 4630): debugger: waiting debug socket connect i/qt java ( 4630): debugger: go sleep i/qt java ( 4630): debugger: waiting debug socket connect i/qt java ( 4630): debugger: go sleep i/qt java ( 4630): debugger: waiting debug socket connect i/qt java ( 4630): debugger: go sleep i/qt java ( 4630): debugger: waiting debug socket connect i/qt java ( 4630): debugger: go sleep i/qt java ( 4630): debugger: waiting debug socket connect not load shared library symbols 88 libraries, e.g. /system/bin/linker. use "info sharedlibrary" command see complete listing. need "set solib-search-path" or "set sysroot"?unable find dynamic linker breakpoint function. gdb unable debug shared library initializers , track explicitly loaded dynamic code.i/qt java ( 4630): debugger: go sleep i/qt java ( 4630): debugger: incoming socket ok i/qt java ( 4630): debugger: got pid acknowledgment i/qt java ( 4630): debugger: ping not requested i/qt java ( 4630): debugger: pong not requested w/qt a11y ( 4630): not activate platform accessibility. d/ ( 4630): hostconnection::get() new host connection established 0xb7383e58, tid 4666 d/ ( 4630): hostconnection::get() new host connection established 0xb73891a8, tid 4630 w/egl_emulation( 4630): eglsurfaceattrib not implemented d/openglrenderer( 4630): enabling debug mode 0 d/libappturista.so( 4630): (null):0 ((null)): qml debugger: waiting connection on port 55091... d/libappturista.so( 4630): ../appturista/manejadorbd.cpp:11 (manejadorbd::manejadorbd(qobject*)): (manejadordb)apertura de base de datos local: false d/libappturista.so( 4630): ../appturista/manejadorbd.cpp:24 (bool manejadorbd::cargardatosdblocal()): (manejadordb)cargando datos desde db local w/libappturista.so( 4630): (null):0 ((null)): qsqlquery::exec: database not open d/libappturista.so( 4630): ../appturista/main.cpp:20 (int main(int, char**)): error al obtener tamaño de la pantalla. d/libappturista.so( 4630): no se puede continuar asi. d/libappturista.so( 4630): ../appturista/globalcontrolclass.cpp:30 (virtual globalcontrolclass::~globalcontrolclass()): (globalcontrolclass)borrando controlador global d/libappturista.so( 4630): ../appturista/manejadorbd.cpp:14 (virtual manejadorbd::~manejadorbd()): (manejadordb)liberando de memoria lista de promociones y bases de datos d/dalvikvm( 4630): threadid=12: thread exiting, not yet detached (count=0) debugging has finished "org.qtproject.example.appturista" terminated.
my main.cpp:
#include <qapplication> #include <qqmlapplicationengine> #include <qdebug> #include <qscreen> #include <qqmlcontext> #include "globalcontrolclass.h" int main(int argc, char *argv[]) { qapplication app(argc, argv); qqmlapplicationengine engine; globalcontrolclass controlglobal; qrect z = qapp->primaryscreen()->availablegeometry(); controlglobal.setwindowheight(z.height()); controlglobal.setwindowwidth(z.width()); if(z.height()<=0 || z.width()<=0){ qdebug()<<"error al obtener tamaño de la pantalla.\nno se puede continuar asi."; return false; } qdebug()<<"window dip-> h:"<<controlglobal.windowheight()<<"w:"<<controlglobal.windowwidth(); engine.rootcontext()->setcontextproperty("controlglobal", &controlglobal); engine.load(qurl(qstringliteral("qrc:/main.qml"))); return app.exec(); }
i use qt creator 3.3.1 qt 5.4.1 (gcc 4.6.1, 64 bit) amv arm (armeabi-v7a) target: android 4.4.2 (api level 19)
solve problem in following way. change qapp->primaryscreen()->availablegeometry();
qapp->desktop()->availablegeometry();
, , if got available screen size, solution important main function begins in following way qapplication app(argc, argv);
main.cpp:
#include <qapplication> // <== important #include <qqmlapplicationengine> #include <qdebug> // <= intention of testing #include <qscreen> // <== important #include <qdesktopwidget> // <== #include <qqmlcontext> #include "globalcontrolclass.h" int main(int argc, char *argv[]){ qapplication app(argc, argv); qqmlapplicationengine engine; globalcontrolclass controlglobal; qrect z = qapp->desktop()->screengeometry(); controlglobal.setwindowheight(z.height()); controlglobal.setwindowwidth(z.width()); qdebug()<<"window dip-> h:"<<controlglobal.windowheight()<<"w:"<<controlglobal.windowwidth(); if(z.height()<=0 || z.width()<=0){ qdebug()<<"error al obtener tamaño de la pantalla.\nno se puede continuar asi."; return false; } engine.rootcontext()->setcontextproperty("controlglobal", &controlglobal); engine.load(qurl(qstringliteral("qrc:/main.qml"))); return app.exec(); }
Comments
Post a Comment