Answer the question
In order to leave comments, you need to log in
Why does QML crash when the timer starts?
To poll the modem, a timer is used on the QML side. Every 30ms, it sends a request to the SerialPort special class and writes the response to the console.
QML Code
Timer {
id: timer1
interval: 30
repeat: true
running: false
onTriggered: {
consile.append(sePort.readDataPort());
}
}
...
ToolButton {
id: callBt
x: 10
y: 0
width: 50
height: 50
text: "Connect"
Layout.rowSpan: 1
Layout.fillWidth: false
Layout.fillHeight: true
transformOrigin: Item.Center
antialiasing: false
smooth: false
scale: 1
tooltip: "Connect"
iconSource: "images/connect.png"
iconName: "connect.png"
visible: true
anchors.verticalCenterOffset: 0
anchors.verticalCenter: parent.verticalCenter
action: Action{
shortcut: "Ctrl + F5"
onTriggered: {
sePort.openPort();
if(sePort.stance() === true){
timer1.start(); // Скорее всего ошибка именно здесь, если убрать эту строчку остальное работает.
consile.append("Соединение установлено");
stance.text = "Соединение: Подключено"
stance.color = "Green"
} else {
consile.append("Ошибка соединения");
stance.text = "Соединение: Не соединено"
stance.color = "Black"
}
}
}
}
ToolButton {
id: discallBt
x: 70
width: 50
height: 50
text: "Disconnect"
iconSource: "images/disconnect.png"
tooltip: "Disconnect"
Layout.fillHeight: true
action: Action{
shortcut: "Ctrl + F5"
onTriggered: {
sePort.closePort();
if (sePort.stance() !== true){
<b>timer1.stop();</b>
stance.text = "Соединение: Не соединено"
stance.color = "Black"
}
consile.text = "";
}
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question