App crashing when I change the value of the slider it just crashes
-
I want to rotate my item arround x-axis, so I have an slider to select the rotation. Everything is okay until I touch the slider. When I touch it, the app just crashes with an code 0. Can anyone help me?
mainwindow.cpp
#include "mainwindow.h" #include "ui_mainwindow.h" #include <QVariant> #include <QQuickItem> MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) , ui(new Ui::MainWindow) { ui->setupUi(this); ui->quickWidget->setSource(QUrl(QStringLiteral("qrc:/gyroscope.qml"))); ui->quickWidget->show(); auto obj = ui->quickWidget->rootObject(); connect(this, SIGNAL(on_open_clicked()), obj, SLOT(chargeObject())); connect(this, SIGNAL(on_print_clicked()), obj, SLOT(printValue())); connect(this, SIGNAL(changeValue(QVariant)), obj, SLOT(changeRotation(QVariant))); } MainWindow::~MainWindow() { delete ui; } void MainWindow::on_xSlider_valueChanged(int value) { emit changeValue(value); }gyroscope.qml
import QtQuick.Controls 2.2 import QtQuick.Dialogs 1.2 import QtQuick 2.0 import QtQuick.Scene3D 2.15 import Qt3D.Core 2.5 import Qt3D.Render 2.15 import Qt3D.Input 2.12 import Qt3D.Extras 2.15 Rectangle { id: window FileDialog { id: fileDialog onAccepted: { sceneLoader.source = fileDialog.fileUrl } } Scene3D { anchors.fill: parent aspects: ["input", "logic"] cameraAspectRatioMode: Scene3D.AutomaticAspectRatio Entity { id: sceneRoot Camera { id: camera projectionType: CameraLens.PerspectiveProjection fieldOfView: 30 aspectRatio: 16/9 nearPlane : 0.1 farPlane : 1000.0 position: Qt.vector3d( 0.0, 0.0, -100.0 ) upVector: Qt.vector3d( 0.0, 1.0, 0.0 ) viewCenter: Qt.vector3d( 0.0, 0.0, 0.0 ) } OrbitCameraController { camera: camera } components: [ RenderSettings { activeFrameGraph: ForwardRenderer { clearColor: Qt.rgba(1, 1, 1, 1) camera: camera } }, InputSettings { } ] Entity { id: monkeyEntity components: [ SceneLoader { id: sceneLoader }, Transform { id: transform rotationY: 0; rotationZ: 0; } ] } Axis { id: axis } } } function printValue() { console.log(axis.value) } function chargeObject() { fileDialog.open() } function changeRotation(value) { transform.rotationX = value } } -
I used it and it reveals nothing. I know the error is in the transformation, but not exacly where-
-

The pane at the bottom of this screen shot is a stack trace, indicating which functions are being called.Using an interactive debugger such as Qt Creator, we can click through the stack and examine the local variables in each frame. In this case, we can see that the char *s is a nullptr. Trying to access s[1] is invalid in this case, leading to the crash.
-
Do you mean this?
The organization name and domain are not the problem because it worked before using that.@GGG03 said in App crashing when I change the value of the slider it just crashes:
Do you mean this?I suspect the native code debugger will be more informative, but this might be enough. Is the transform object valid? Does it have a rotationX member? Is value valid to assign to it?
The organization name and domain are not the problem because it worked before using that.
Try eliminating that, and everything else that isn't essential to trigger the crash. Smaller programs make for easier problems to solve.
-
In theory transform has it, it is the fuction https://doc.qt.io/qt-6/qt3dcore-qtransform.html#rotationX-prop
I tried to change the rotation value int for a float but it still crushes. I suspect the function is wrong, but I dont know why . -
In theory transform has it, it is the fuction https://doc.qt.io/qt-6/qt3dcore-qtransform.html#rotationX-prop
I tried to change the rotation value int for a float but it still crushes. I suspect the function is wrong, but I dont know why .@GGG03 said in App crashing when I change the value of the slider it just crashes:
In theory transform has it
Use the debugger to validate that theory. Look at the values of all objects involved.
Print statements also work.function changeRotation(value) { console.log("transform =", transform); console.log("transform.rotationX =", transform.rotationX); console.log("value =", value); transform.rotationX = value; console.log("assignment did not crash"); }