I'm measuring it on Windows, so it's probably not much use. Tomorrow I can have a go at it on a Linux machine. Anyways, the result is still strange. Here is how I did the performance measuring:
void transferAnglesToSpinboxes()
{
disconnect(this, SIGNAL(inputValueChanged()), this, SLOT(jointAnglesChangedBySpinbox()));
time.start();
headY->setValue(jointAngles["headY"]);
headZ->setValue(jointAngles["headZ"]);
[...]
lAnkX->setValue(jointAngles["lAnkX"]);
lAnkY->setValue(jointAngles["lAnkY"]);
qDebug() << time.elapsed();
connect(this, SIGNAL(inputValueChanged()), this, SLOT(jointAnglesChangedBySpinbox()));
}
void transferAnglesToSpinboxes()
{
disconnect(this, SIGNAL(inputValueChanged()), this, SLOT(jointAnglesChangedBySpinbox()));
QTime time;
time.start();
headY->setValue(jointAngles["headY"]);
headZ->setValue(jointAngles["headZ"]);
[...]
lAnkX->setValue(jointAngles["lAnkX"]);
lAnkY->setValue(jointAngles["lAnkY"]);
qDebug() << time.elapsed();
connect(this, SIGNAL(inputValueChanged()), this, SLOT(jointAnglesChangedBySpinbox()));
}
To copy to clipboard, switch view to plain text mode
The result is something like:
0,16,15,16,16,42,15,16,0,16,16,15...say 16 ms.
In the meantime I implemented a quick hack to protect the spin boxes from being updated too often like this:
// An ugly quick hack to circumvent performance issues.
if (lastTime.
msecsTo(QTime::currentTime()) >
100) {
lastTime
= QTime::currentTime();
transferAnglesToSpinboxes();
}
// An ugly quick hack to circumvent performance issues.
if (lastTime.msecsTo(QTime::currentTime()) > 100)
{
lastTime = QTime::currentTime();
transferAnglesToSpinboxes();
}
To copy to clipboard, switch view to plain text mode
With this protection is on, the performance measure shows:
0,0,0,0,0,0,0,0,0,0,0,0,16,0,0,0,0,0,0,0,0...as if it were nothing.
Yes.
Why you are using signal and slots to communicate inside a class?
I tried to explain in my first post, I guess it was too lame. Of course the spin boxes can be changed manually by the user and each of them emits an individual valueChanged() signal. This also happens when I set the value of the spin box programatically. But in the latter case I want to supress the valueChanged() signals. So what I did is I connected the valueChanged() signals of all the spin boxes to one inputValueChanged() signal of my class, which is then connected to a slot that handles the transfer of the spin box values into the jointAngles QHash. As you can see in my transferAnglesToSpinboxes() methid, this way I only need to disconnect one signal, when I change the spin boxes programatically. Otherwise I would have to disconnect and then reconnect 20 individual spin boxes.
Bookmarks