QJsondocument slowness when hooked up to a QSlider
-
@mrjj sadly it looks like if i can't controll / adjust / remove the queue system from QNAM im stuck using either "requests", "httplib2" or "urllib3" as they are instant :/ i can't have that queue system it takes ages befor the brightness levels of the LED's are where the slider is set to :/
@Kris-Revi said in QJsondocument slowness when hooked up to a QSlider:
@mrjj sadly it looks like if i can't controll / adjust / remove the queue system from QNAM im stuck using either "requests", "httplib2" or "urllib3" as they are instant :/ i can't have that queue system it takes ages befor the brightness levels of the LED's are where the slider is set to :/
I'm pretty sure with QNAM you're flooding the device sending near 10 times the payload (i.e. you're DoS-ing your device). What you can and should do instead is to disentangle the slider from the communication and buffer the slider's events instead of flushing them directly through the network. That is you introduce a timer that ticks every 200ms or so (which is below the typical reaction time of a human anyway), and send a message to the device if the slider's value has changed in the meantime. In Qt this'd look something like this:
QObject::connect(slider, &QAbstractSlider::valueChanged, controller, &ControllerClass::setValue); QObject::connect(timer, &QTimer::timeout, controller, &ControllerClass::sendNetworkData);
where all the slots and signals do the obvious - the
ControllerClass::setValue
just saves the new value and if it's different from the previous raises an internaldirty
state.ControllerClass::sendNetworkData
checks if the state isdirty
, and if so, sends the new data and resets the flag.