PDA

View Full Version : Porting from Qwt5.2.1 to Qwt6.1 / QwtSlider::setRange



Induriel
1st April 2014, 16:03
Hi,

I try to port my application from Qt4 to Qt5 and Qwt5.2.1 to Qwt6.1.

Actually the app starts, but it takes much longer to instantiate the widgets (3s before, >70s now). The reason semms to be QwtSlider::setRange() (Qwt5.2.1) and QwtSlider::setScale() (Qwt6.1). If I comment out the setScale() in the ported app, the instantiation is as fast as it was before.
I'm using the QwtSlider with setScalePosition(QwtSlider::NoScale), so I don't expect to have lots of painting of scales, but I may be wrong there.

So my question is: how can I adjust my QwtSlider to a certain range with a stepsize as in Qwt5.2.1 using Qwt6.1 without the obvious overhead? Is it possible to switch "it" off?

Thanks and best regards,
Carsten

Uwe
1st April 2014, 16:57
70s sounds very insane - nothing what makes for initializing a slider. Maybe there are slots connected to the slider that run into expensive code - maybe running into a loop reinitialization of the slider ?

Uwe

Induriel
1st April 2014, 17:43
I tested for a loop, but there's no loop, each slider is instantiated only once,

_slider->setScale(lowerBorder, upperBorder);
_slider->setScaleStepSize(stepSize);

is called only once at instantiation time. There're ~400 QwtSlider in the application, but I think, this shouldn't matter. And the same (unported) application runs fine with

_slider->setRange(lowerBorder, upperBorder, stepSize);

Yes, there're slots connected to the slider. But if I run into expensive code with setScale(), I should run into the same code with setRange(), too, since I just exchanged setRange() for setScale() + setScaleStepSize().

Carsten

Added after 15 minutes:

Here's some code to reproduce this behaviour, just activate/deactivate setScale/setScaleStepSize.

#include <QtWidgets/QApplication>
#include <QWidget>
#include <QVBoxLayout>
#include <QDebug>
#include "qwt_slider.h"

class TestQwtSlider : public QWidget {

public:
TestQwtSlider(QWidget *parent = 0) {

QwtSlider *slider[100];

QVBoxLayout *layout = new QVBoxLayout;

for (int i=0; i<100; i++) {
slider[i] = new QwtSlider;
layout->addWidget(slider[i]);

slider[i]->setStyleSheet("QFrame { background-color: blue; }");
slider[i]->setFixedWidth(100);
slider[i]->setOrientation(Qt::Horizontal);
slider[i]->setScalePosition(QwtSlider::NoScale);
slider[i]->setTrough(true);
slider[i]->setStyleSheet("QFrame { background-color: blue; }");
//slider[i]->setScale(0, 1000);
//slider[i]->setScaleStepSize(0.1);
qDebug() << i;
}

setLayout(layout);
}
};


int main(int argc, char *argv[])
{


QApplication a(argc, argv);

TestQwtSlider w;
w.show();
return a.exec();

}

I forgot: I'm running Win7 64, don't know what's happening on Linux.

Best regards,
Carsten

Uwe
2nd April 2014, 06:54
Here's some code to reproduce this behaviour, just activate/deactivate setScale/setScaleStepSize.
I can see that the call of "slider[i]->setScaleStepSize(0.1);" has an impact of 3ms for each slider ( without this call each slider is created in 0 ms ). IMO this step size ( = setting 10000 ticks for each slider ! ) doesn't make any sense on displays with a resolution in ranges below 2000 pixels - especially considering that you don't display the scale at all !

Guess what you want to set here are the increments of the slider ( not the ticks of the scale ), what can be done with the methods you find in the QwtAbstractSlider API. Here you have to set the number of the steps - not a step size - because a step size wouldn't work for sliders with non linear transformations ( f.e logarithmic scales ).

Uwe

Induriel
2nd April 2014, 09:52
I see. setScaleStepSize() != setSingleSteps() != setTotalSteps()
And setTotalSteps() is what I really want as you guessed.
Thanks for the hint!

Carsten