Added init after timer. single shot.

This commit is contained in:
2026-01-01 02:40:12 +01:00
parent 550382207e
commit 3825ce8647

View File

@@ -30,7 +30,7 @@
***************************************************************************/
//#include <QToolButton>
#include <QTimer>
#include "qassert.h"
#include <bcmainwindow.h>
@@ -51,8 +51,11 @@ BCMainWindow::BCMainWindow(QWidget *parent)
qRegisterMetaType<QList<BCValue>>("BCValueList");
setupUi(this);
initMainWindow();
// BESTE PRAXIS: QTimer::singleShot mit Lambda
QTimer::singleShot(0, this, [this]() {
initMainWindow();
});
}
@@ -111,6 +114,7 @@ void BCMainWindow::initMainWindow()
}
};
// Wir wollen die Devices den Views zuordnen können
_devicePanels[BCDevice::ID::Console] = _consolePanel;
_devicePanels[BCDevice::ID::Battery] = _batteryPanel;
@@ -147,11 +151,8 @@ void BCMainWindow::initMainWindow()
// also: emit dataChanged(index, index, {Qt::DisplayRole, Qt::EditRole, ValueRole});
connect( _connectButton, &QToolButton::clicked, &_transmitter, &BCTransmitter::onToggleConnectionState );
connect( _syncButton, &QToolButton::clicked, this, &BCMainWindow::onSyncFromDevice );
connect( &_transmitter, &BCTransmitter::valueUpdated, this, &BCMainWindow::onValueUpdated );
// die Daten des eBikes laden
_dataManager.loadXmlBikeData(":/bikeinfo.xml"_L1);
_transmitter.moveToThread(&_worker);
@@ -160,6 +161,10 @@ void BCMainWindow::initMainWindow()
_worker.start();
bc::processEventsFor(2000);
// die Daten des eBikes laden
_dataManager.loadXmlBikeData(":/bikeinfo.xml"_L1);
_consoleAction->trigger();
}