gpt4 book ai didi

android - Android 上 Qt 5.3 RC 中的 QtPositioning 错误

转载 作者:行者123 更新时间:2023-11-28 02:48:01 26 4
gpt4 key购买 nike

我正在 Android 上的 Qt 5.3 RC 中试验 Qt 定位。这是我的代码示例,我在其中创建位置和卫星源:

QGeoPositionInfoSource *source = QGeoPositionInfoSource::createDefaultSource(this);
if (source) {
QStringList posSourcesList = QGeoPositionInfoSource::availableSources();
qDebug() << "Position sources count: " << posSourcesList.count();
foreach (const QString &src, posSourcesList) {
qDebug() << "pos source in list: " << src;
}

source->startUpdates();
connect(source, SIGNAL(positionUpdated(QGeoPositionInfo)),
this, SLOT(positionUpdated(QGeoPositionInfo)));
}
//----------------------------------------------------------------------------------

QGeoSatelliteInfoSource *satelliteSource = QGeoSatelliteInfoSource::createDefaultSource(this);
if(satelliteSource)
{
QStringList sourcesList = QGeoSatelliteInfoSource::availableSources();
qDebug() << "Satellites sources count: " << sourcesList.count();
foreach (const QString &src, sourcesList) {
qDebug() << "source in list: " << src;
}

satelliteSource->startUpdates();
connect(satelliteSource, SIGNAL(satellitesInViewUpdated(QList<QGeoSatelliteInfo>)),
this, SLOT(satellitesInViewUpdated(QList<QGeoSatelliteInfo>)));
}

我对输出进行了分割:

D/Qt      (16403): ../test_GPS/gpshandler.cpp:14 (GPSHandler::GPSHandler(QObject*)): Position sources count:  1
D/Qt (16403): ../test_GPS/gpshandler.cpp:16 (GPSHandler::GPSHandler(QObject*)): pos source in list: "android"
D/QtPositioning(16403): Regular updates using GPS
D/QtPositioning(16403): Regular updates using network
D/Qt (16403): ../test_GPS/gpshandler.cpp:37 (GPSHandler::GPSHandler(QObject*)): Satellites sources count: 1
D/Qt (16403): ../test_GPS/gpshandler.cpp:39 (GPSHandler::GPSHandler(QObject*)): source in list: "android"
F/Qt (16403): jnipositioning.cpp:496 (void satelliteUpdated(JNIEnv*, jobject, jobjectArray, jint, jboolean)): satelliteUpdated: source == 0

这是回溯:

0 ?? /home/qtproj/build-test_GPS-Android_for_armeabi_v7a_GCC_4_8_Qt_5_3_0-Debug/libc.so  0x4010a8e8
1 abort /home/qtproj/build-test_GPS-Android_for_armeabi_v7a_GCC_4_8_Qt_5_3_0-Debug/libc.so 0x40108948
2 QMessageLogger::fatal(char const*, ...) const /opt/Qt-5.3.0_rc/5.3/android_armv7/lib/libQt5Core.so 0x75357ff6
3 satelliteUpdated(_JNIEnv*, _jobject*, _jobjectArray*, int, unsigned char) /opt/Qt-5.3.0_rc/5.3/android_armv7/plugins/position/libqtposition_android.so 0x751a8c08
4 ?? 0x40b3a910
5 ?? 0x40b3a910

当我仅创建 QGeoPositionInfoSource 或仅创建 QGeoSatelliteInfoSource 时,不会发生此错误。有什么建议吗?

最佳答案

同样的错误在5.3.1中依然存在。我没有要提供的解释,但这里的解决方法是更改​​源的初始化顺序。

  1. QGeoSatelliteInfoSource
  2. QGeoPositionInfoSource

所以在你的代码中会是

QGeoSatelliteInfoSource *satelliteSource = QGeoSatelliteInfoSource::createDefaultSource(this);
if(satelliteSource) {
QStringList sourcesList = QGeoSatelliteInfoSource::availableSources();
qDebug() << "Satellites sources count: " << sourcesList.count();
foreach (const QString &src, sourcesList) {
qDebug() << "source in list: " << src;
}

satelliteSource->startUpdates();
connect(satelliteSource, SIGNAL(satellitesInViewUpdated(QList<QGeoSatelliteInfo>)),
this, SLOT(satellitesInViewUpdated(QList<QGeoSatelliteInfo>)));
}

QGeoPositionInfoSource *source = QGeoPositionInfoSource::createDefaultSource(this);
if (source) {
QStringList posSourcesList = QGeoPositionInfoSource::availableSources();
qDebug() << "Position sources count: " << posSourcesList.count();
foreach (const QString &src, posSourcesList) {
qDebug() << "pos source in list: " << src;
}

source->startUpdates();
connect(source, SIGNAL(positionUpdated(QGeoPositionInfo)),
this, SLOT(positionUpdated(QGeoPositionInfo)));
}

关于android - Android 上 Qt 5.3 RC 中的 QtPositioning 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23737781/

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