gpt4 book ai didi

android - Qt Android qApp->primaryScreen()->availableGeometry() 返回 0x0

转载 作者:塔克拉玛干 更新时间:2023-11-03 07:50:21 26 4
gpt4 key购买 nike

如果我在桌面(Linux 或 Windows)上使用,在应用程序中使用 qApp->primaryScreen()->availableGeometry(); 时获取可用屏幕的大小,这对我是因为应用程序的每个元素的大小是根据屏幕上可用的高度和宽度计算的,但是在 ADV 上运行时总是返回 0x0,这会阻止正确的应用程序功能。如果我尝试在物理设备中部署,调试器和应用程序甚至不会开始。在我得到的完整日志中是这样的:

Debugging starts
D/dalvikvm( 4630): Not late-enabling CheckJNI (already on)
I/dalvikvm( 4630): Zip is good, but no classes.dex inside, and no valid .odex file in the same directory
I/dalvikvm( 4630): Zip is good, but no classes.dex inside, and no valid .odex file in the same directory
I/dalvikvm( 4630): Zip is good, but no classes.dex inside, and no valid .odex file in the same directory
I/dalvikvm( 4630): Zip is good, but no classes.dex inside, and no valid .odex file in the same directory
D/dalvikvm( 4630): Trying to 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 to 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 to 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 to 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 to 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 to 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 to 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 to 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 to 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 to 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 to 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 to 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 to load lib /data/local/tmp/qt/lib/libQt5QuickParticles.so 0xb2d01db8
D/dalvikvm( 4630): Shared lib '/data/local/tmp/qt/lib/libQt5QuickParticles.so' already loaded in same CL 0xb2d01db8
D/dalvikvm( 4630): Trying to 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 to load lib /data/app-lib/org.qtproject.example.appTurista-1/libappTurista.so 0xb2cda5c8
D/ ( 4630): (null):0 ((null)): QML debugging is enabled. Only use this in a 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: extra 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 for socket at /data/data/org.qtproject.example.appTurista/debug-socket, attempt 0
I/Qt JAVA ( 4630): DEBUGGER: waiting for socket at /data/data/org.qtproject.example.appTurista/debug-socket, attempt 1
I/Qt JAVA ( 4630): DEBUGGER: socket ok
I/Qt JAVA ( 4630): DEBUGGER: Waiting for debug socket connect
I/Qt JAVA ( 4630): DEBUGGER: go to sleep
I/Qt JAVA ( 4630): DEBUGGER: Waiting for debug socket connect
I/Qt JAVA ( 4630): DEBUGGER: go to sleep
I/Qt JAVA ( 4630): DEBUGGER: Debug socket accepted
I/Qt JAVA ( 4630): DEBUGGER: Waiting for debug socket connect
I/Qt JAVA ( 4630): DEBUGGER: go to sleep
I/Qt JAVA ( 4630): DEBUGGER: Waiting for debug socket connect
I/Qt JAVA ( 4630): DEBUGGER: go to sleep
I/Qt JAVA ( 4630): DEBUGGER: Waiting for debug socket connect
I/Qt JAVA ( 4630): DEBUGGER: go to sleep
I/Qt JAVA ( 4630): DEBUGGER: Waiting for debug socket connect
I/Qt JAVA ( 4630): DEBUGGER: go to sleep
I/Qt JAVA ( 4630): DEBUGGER: Waiting for debug socket connect
I/Qt JAVA ( 4630): DEBUGGER: go to sleep
I/Qt JAVA ( 4630): DEBUGGER: Waiting for debug socket connect
I/Qt JAVA ( 4630): DEBUGGER: go to sleep
I/Qt JAVA ( 4630): DEBUGGER: Waiting for debug socket connect
I/Qt JAVA ( 4630): DEBUGGER: go to sleep
I/Qt JAVA ( 4630): DEBUGGER: Waiting for debug socket connect
I/Qt JAVA ( 4630): DEBUGGER: go to sleep
I/Qt JAVA ( 4630): DEBUGGER: Waiting for debug socket connect
I/Qt JAVA ( 4630): DEBUGGER: go to sleep
I/Qt JAVA ( 4630): DEBUGGER: Waiting for debug socket connect
I/Qt JAVA ( 4630): DEBUGGER: go to sleep
I/Qt JAVA ( 4630): DEBUGGER: Waiting for debug socket connect
I/Qt JAVA ( 4630): DEBUGGER: go to sleep
I/Qt JAVA ( 4630): DEBUGGER: Waiting for debug socket connect
I/Qt JAVA ( 4630): DEBUGGER: go to sleep
I/Qt JAVA ( 4630): DEBUGGER: Waiting for debug socket connect
I/Qt JAVA ( 4630): DEBUGGER: go to sleep
I/Qt JAVA ( 4630): DEBUGGER: Waiting for debug socket connect
I/Qt JAVA ( 4630): DEBUGGER: go to sleep
I/Qt JAVA ( 4630): DEBUGGER: Waiting for debug socket connect
I/Qt JAVA ( 4630): DEBUGGER: go to sleep
I/Qt JAVA ( 4630): DEBUGGER: Waiting for debug socket connect
I/Qt JAVA ( 4630): DEBUGGER: go to sleep
I/Qt JAVA ( 4630): DEBUGGER: Waiting for debug socket connect
I/Qt JAVA ( 4630): DEBUGGER: go to sleep
I/Qt JAVA ( 4630): DEBUGGER: Waiting for debug socket connect
I/Qt JAVA ( 4630): DEBUGGER: go to sleep
I/Qt JAVA ( 4630): DEBUGGER: Waiting for debug socket connect
I/Qt JAVA ( 4630): DEBUGGER: go to sleep
I/Qt JAVA ( 4630): DEBUGGER: Waiting for debug socket connect
I/Qt JAVA ( 4630): DEBUGGER: go to sleep
I/Qt JAVA ( 4630): DEBUGGER: Waiting for debug socket connect
I/Qt JAVA ( 4630): DEBUGGER: go to sleep
I/Qt JAVA ( 4630): DEBUGGER: Waiting for debug socket connect
I/Qt JAVA ( 4630): DEBUGGER: go to sleep
I/Qt JAVA ( 4630): DEBUGGER: Waiting for debug socket connect
I/Qt JAVA ( 4630): DEBUGGER: go to sleep
I/Qt JAVA ( 4630): DEBUGGER: Waiting for debug socket connect
I/Qt JAVA ( 4630): DEBUGGER: go to sleep
I/Qt JAVA ( 4630): DEBUGGER: Waiting for debug socket connect
Could not load shared library symbols for 88 libraries, e.g. /system/bin/linker.
Use the "info sharedlibrary" command to see the complete listing.
Do you need "set solib-search-path" or "set sysroot"?Unable to find dynamic linker breakpoint function.
GDB will be unable to debug shared library initializers
and track explicitly loaded dynamic code.I/Qt JAVA ( 4630): DEBUGGER: go to 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): Could 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 for 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.

我的 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();
}

我使用 Qt Creator 3.3.1 Qt 5.4.1 (GCC 4.6.1, 64 位)AMV 是 ARM (armeabi-v7a) 目标:Android 4.4.2(API 级别 19)

最佳答案

按以下方式解决我的问题。将 qApp->primaryScreen()->availableGeometry(); 更改为 qApp->desktop()->availableGeometry();,如果我得到可用的屏幕尺寸,此解决方案对于主要函数以以下方式开始很重要 QApplication app(argc, argv);

主要.cpp:

#include <QApplication>      // <== this is important
#include <QQmlApplicationEngine>

#include <QDebug> // <= with the intention of testing

#include <QScreen> // <== this is 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();
}

关于android - Qt Android qApp->primaryScreen()->availableGeometry() 返回 0x0,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30175324/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com