Results 1 to 5 of 5

Thread: Porting from Qwt5.2.1 to Qwt6.1 / QwtSlider::setRange

  1. #1
    Join Date
    Apr 2014
    Posts
    13
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Porting from Qwt5.2.1 to Qwt6.1 / QwtSlider::setRange

    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

  2. #2
    Join Date
    Feb 2006
    Location
    Munich, Germany
    Posts
    3,312
    Thanked 879 Times in 827 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Porting from Qwt5.2.1 to Qwt6.1 / QwtSlider::setRange

    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

  3. #3
    Join Date
    Apr 2014
    Posts
    13
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Porting from Qwt5.2.1 to Qwt6.1 / QwtSlider::setRange

    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
    Last edited by Induriel; 1st April 2014 at 17:43.

  4. #4
    Join Date
    Feb 2006
    Location
    Munich, Germany
    Posts
    3,312
    Thanked 879 Times in 827 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Porting from Qwt5.2.1 to Qwt6.1 / QwtSlider::setRange

    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

  5. #5
    Join Date
    Apr 2014
    Posts
    13
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Porting from Qwt5.2.1 to Qwt6.1 / QwtSlider::setRange

    I see. setScaleStepSize() != setSingleSteps() != setTotalSteps()
    And setTotalSteps() is what I really want as you guessed.
    Thanks for the hint!

    Carsten
    Last edited by Induriel; 2nd April 2014 at 09:57.

Similar Threads

  1. QwtSlider stepSize
    By snowbound in forum Qwt
    Replies: 5
    Last Post: 14th March 2014, 13:46
  2. QwtThermo: What happened to setRange?
    By jeroenz2 in forum Qwt
    Replies: 1
    Last Post: 13th August 2013, 08:59
  3. QwtSlider resize
    By vratojr in forum Qwt
    Replies: 1
    Last Post: 13th July 2011, 12:28
  4. Can I call setRange multiple times for QProgressBar ?
    By elizabeth.h1 in forum Qt Programming
    Replies: 2
    Last Post: 30th April 2010, 07:18
  5. Replies: 0
    Last Post: 21st September 2009, 17:25

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.