Correct me if I'm wrong but if you change values to those spinboxes every 20ms, they need to be redrawn 50 times per second. 50 * 20 = 1000. That's how many times per second the paintEvent of the spinbox class is called.
I suggest you do something like this:
QVector<qreal> values(20, 0.0);
connect(updateTimer, SIGNAL(timeout()), this, SLOT(updateBoxes()));
updateTimer->start(500); // 2Hz
//...
void XX::updateBoxes(){
for(int i=0;i<20;i++){
qreal val = values[i];
sb->setValue(val);
}
}
QVector<qreal> values(20, 0.0);
QTimer *updateTimer = new QTimer(this);
connect(updateTimer, SIGNAL(timeout()), this, SLOT(updateBoxes()));
updateTimer->start(500); // 2Hz
//...
void XX::updateBoxes(){
for(int i=0;i<20;i++){
qreal val = values[i];
QDoubleSpinBox *sb = boxes[i];
sb->setValue(val);
}
}
To copy to clipboard, switch view to plain text mode
That's more or less what you did in your first approach. Just make sure the "transferAxesToSpinboxes()" method is called 1-2 times a second at most. You won't notice more values of 20 boxes per second anyway.
Bookmarks