PDA

View Full Version : QwtScaleDraw class not working



Tomas_Zajic
26th August 2015, 12:29
Hello!

I don't know why the code below is not working and I can't explain the way
1) widget->setScaleDraw(new draw()); calls the class draw so that it doesn't setAlignment on the widget.
I know two other ways to put it right such as
2) widget->setAlignment(QwtScaleDraw::TopScale);)
3) widget->setScaleDraw(inst_draw = new draw());
But im not interested in them. I would like to particularly know why the first option is not working and what I'm missing to know.Thank you a lot!

class draw:public QwtScaleDraw{
public:
draw();
};

draw::draw(){this->setAlignment(QwtScaleDraw::TopScale);};

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

QwtScaleWidget* widget = new QwtScaleWidget;
widget->setScaleDraw(new draw());
widget->show();


return a.exec();
}

Uwe
26th August 2015, 15:57
Qwt is open source - looking at the code of QwtScaleWidget::setScaleDraw() and you will see immediately why the line in the constructor of draw doesn't have any effect.

Uwe