QtLocation test app freezes of startup using the open streetmap provider? - qt

I'm trying to get qtlocation running with the osm provider but for some reason when the application starts up it just hangs. Cannot even close it.
When I change it to use the "mapboxgl" provider it works fine. I've been using it for many years on ubuntu 20.04 but since I've switched to Ubuntu 22.04 (qt 5.15.3) I'm having issues. Am I missing parameters?
using gcc 11.3.0
Any help would be appreciated
I'm running Qt's test/example app qt's example code
main.cpp:
#include <QGuiApplication>
#include <QQmlApplicationEngine>
int main(int argc, char *argv[])
{
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
#endif
QGuiApplication app(argc, argv);
QQmlApplicationEngine engine;
const QUrl url(QStringLiteral("qrc:/main.qml"));
QObject::connect(&engine, &QQmlApplicationEngine::objectCreated,
&app, [url](QObject *obj, const QUrl &objUrl) {
if (!obj && url == objUrl)
QCoreApplication::exit(-1);
}, Qt::QueuedConnection);
engine.load(url);
return app.exec();
}
main.qml:
import QtQuick 2.12
import QtQuick.Window 2.12
import QtLocation 5.12
import QtPositioning 5.12
Window {
width: 512
height: 512
visible: true
Plugin {
id: osmPlugin
name: "osm"
// specify plugin parameters if necessary
// PluginParameter {
// name:
// value:
// }
}
Map {
anchors.fill: parent
plugin: osmPlugin
center: QtPositioning.coordinate(59.91, 10.75) // Oslo
zoomLevel: 10
}
}
Then I also tried with qt 5.15.10. same result
Also noted that it stops as soon as it loads 1 tile. every time you run it again you see an extra tile showing(probably cached tiles).

Related

Getting Uncaught Type Error from mapjs.bundle.js in React app

Greetings HERE Developer Support,
I'm seeing numerous Uncaught TypeErrors in the browser console coming from mapjs.bundle.js as I interact with the map in my React app.
I've reproduced the error with the minimal app below. Any insight is much appreciated.
package.json:
{
"type": "module",
"scripts": {
"start": "parcel index.html --open"
},
"devDependencies": {
"parcel": "^2.4.1"
},
"dependencies": {
"#here/maps-api-for-javascript": "^1.30.14",
"react": "^18.0.0",
"react-dom": "^18.0.0"
}
}
index.html:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Map App</title>
</head>
<body>
<div id="root" />
<script src="index.jsx" type="module"></script>
</body>
</html>
index.jsx:
import React from 'react';
import { createRoot } from 'react-dom/client';
import Map from './Map';
const rootElem = document.getElementById("root");
createRoot(rootElem).render(<Map />);
Map.jsx: (copied from the React tutorial at developer.here.com)
import React from 'react';
import H from "#here/maps-api-for-javascript";
export default class Map extends React.Component {
constructor(props) {
super(props);
// the reference to the container
this.ref = React.createRef();
// reference to the map
this.map = null;
}
componentDidMount() {
if (!this.map) {
// instantiate a platform, default layers and a map as usual
const platform = new H.service.Platform({
apikey: MyApiKey
});
const layers = platform.createDefaultLayers();
const map = new H.Map(
this.ref.current,
layers.vector.normal.map,
{
pixelRatio: window.devicePixelRatio,
center: {lat: 0, lng: 0},
zoom: 2,
},
);
this.map = map;
}
}
render() {
return (
<div
style={{ width: '300px', height:'300px' }}
ref={this.ref}
/>
)
}
}
Then run:
npm install && npm start
Please refer below steps, which tell how we can do the react setup.
Setup
For the fast setup of the new React application we will use the Create React App environment. It provides a fast way to get started building a new single-page application. Execute the npx runner as below (it requires Node >= 8.10 and npm >= 5.6):
npx create-react-app jsapi-react && cd jsapi-react
You can check the React setup page for the same.

idle-vue-3 mitt i.$emit is not a function

I am using Quasar 2 Vue 3. When I use idle-vue-3 with mitt in the following way:
import { createApp } from 'vue';
import IdleVue from "idle-vue-3";
import mitt from 'mitt';
import App from "../App.vue";
const app = createApp(App);
const emitter = mitt();
const idleTimeInMillis = 60000;
app.use(IdleVue, {
eventEmitter: emitter, // OR eventEmitter: emitter.emit,
store: Store,
idleTime: idleTimeInMillis,
startAtIdle: false
});
export default app;
I get i.$emit is not a function on the console. Any advice and insight is appreciated.
Remove eventEmitter: emitter,. It is not needed.

Is it possible to add a Uv cube mapping to a CuboidMesh in QML?

I am developping a 3D cube with 6 different textures and I wanted to know if it's possible to use a cube Uv mapping for a CuboidMesh in QML.
If it's possible, how can I do it ?
I try it but I have the following result :
Here is my code for all the scene including the cube :
import Qt3D.Core 2.12
import Qt3D.Render 2.12
import Qt3D.Extras 2.12
import Qt3D.Input 2.12
import QtQuick 2.12
import QtQuick.Scene3D 2.12
import QtQuick.Window 2.12
import QtQuick 2.15
Entity {
id: root
Entity {
id: cubeEntity
Texture2D {
id: cubeTexture
TextureImage {
source: "qrc:/texture.png"
}
}
CuboidMesh {
id: cubeMesh
xExtent: 1
yExtent: 1
zExtent: 1
}
Transform {
id: cubeTransform
}
ObjectPicker {
id: cubePicker
}
NormalDiffuseMapMaterial{
id: cubeMaterial
diffuse: cubeTexture
normal: cubeTexture
specular: "black"
shininess: 50
}
components: [cubeMesh, cubeTransform, cubeMaterial, cubePicker]
}
}
It works with the Mesh type but I want to use that mapping with a CuboidMesh.
My texture.png is the following image :

QML nextItemInFocusChain() not working, always refers to self

Calling nextItemInFocusChain() from a child QML component seems to always return the current component. Understandably, calling forceActiveFocus() on that next item does nothing. Note that navigation via the tab key still works as expected.
Minimally Reproducible Example:
qml.qrc
<RCC>
<qresource prefix="/qml">
<file>main.qml</file>
<file>Child.qml</file>
</qresource>
</RCC>
main.cpp
#include <QGuiApplication>
#include <QQmlApplicationEngine>
#include <QQmlContext>
int main(int argc, char *argv[])
{
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
#endif
QGuiApplication app(argc, argv);
QQmlApplicationEngine engine;
const QUrl url(QStringLiteral("qrc:/qml/main.qml"));
QObject::connect(&engine, &QQmlApplicationEngine::objectCreated,
&app, [url](QObject *obj, const QUrl &objUrl) {
if (!obj && url == objUrl)
QCoreApplication::exit(-1);
}, Qt::QueuedConnection);
engine.load(url);
return app.exec();
} // main
main.qml
import QtQuick 2.12
import QtQuick.Window 2.12
import QtQuick.Controls 2.15
import QtQuick.Layouts 1.12
ApplicationWindow {
width: 800
height: 600
visible: true
visibility: "FullScreen"
title: "HelloWorld"
RowLayout {
spacing: 30
width: 600
Child {
Layout.fillWidth: true
id: test1
}
Child {
Layout.fillWidth: true
id: test2
}
Child {
Layout.fillWidth: true
id: tes3
}
}
onActiveFocusItemChanged: print("activeFocusItem: ", activeFocusItem)
}
child.qml
import QtQuick 2.12
import QtQuick.Controls 2.15
Item {
function focusNext()
{
console.log("focusing next...")
nextItemInFocusChain().forceActiveFocus()
}
Keys.onReturnPressed: focusNext()
TextField {
text: "TEST"
}
}
Putting the logic directly in the TextField results in the correct behavior:
TextField {
...
Keys.onReturnPressed: nextItemInFocusChain().forceActiveFocus()
}
It's unclear to me why the parent item cannot redirect focus in this way.

Declare specific global objects in QML

I am trying to follow this answer, but for more complicated objects:
https://stackoverflow.com/a/25123824/1036082
My files are:
qml.qrc:
<RCC>
<qresource prefix="/">
<file>main.qml</file>
<file>Uconsts.qml</file>
<file>Ucolors.qml</file>
<file>qmldir</file>
</qresource>
</RCC>
main.qml:
import QtQuick 2.9
import QtQuick.Window 2.2
import "."
Window
{
width: 600
height: 400
visible: true
color: Uconsts.colDay.canvas;
}
qmldir:
# qmldir
singleton Uconsts Uconsts.qml
Ucolors.qml:
import QtQuick 2.0
Item
{
property color canvas: "#FFFFFF";
}
Uconsts.qml:
pragma Singleton
import QtQuick 2.9
QtObject
{
property Ucolors colDay:
{
canvas: "#eaedf1";
}
}
When running the program, in runtime I get the following errors from the QML side:
qrc:/main.qml:10: TypeError: Cannot read property 'canvas' of null
qrc:/Uconsts.qml:6:2: Unable to assign QString to Ucolors_QMLTYPE_0*
What am I doing wrong here?
QML does not deduct the type when you use {}, you must create the item explicitly
pragma Singleton
import QtQuick 2.9
QtObject
{
property Ucolors colDay: Ucolors{ canvas: "#eaedf1";}
}

Resources