Hello again,
I have a question on the example code above.
I want to hide/unhide the intervals during runtime, so I have to put the intervals in a container (let it be a QVector or so..). Now MyTransformation should have access to this container. My idea is a new attribute of MyTransformation (a pointer to the container). If I do it that way, I need a pointer to the instance of MyTransformation as attribute of MyScaleEngine (ftuTransformation *trans).
In this case, it's not quite good, that QwtScaleTransformation *transformation() always creates new instances of MyTransformation.
If I do something like:
{
return this->trans;
}
QwtScaleTransformation *ftuScaleEngine::transformation() const
{
return this->trans;
}
To copy to clipboard, switch view to plain text mode
and trans is a pointer to MyTransformation (instantiated in constructor of ftuScaleEngine), I get a seg-fault:
(gdb) bt
#0 0x00007f6ad6535020 in QwtScaleDraw::getBorderDistHint(QFont const&, int&, int&) const () from /usr/lib/libqwt.so.6
#1 0x00007f6ad65747d6 in QwtScaleWidget::getBorderDistHint(int&, int&) const () from /usr/lib/libqwt.so.6
#2 0x00007f6ad654fd21 in QwtPlot::updateAxes() () from /usr/lib/libqwt.so.6
#3 0x00007f6ad654a90a in QwtPlot::replot() () from /usr/lib/libqwt.so.6
#4 0x0000000000416f70 in ScrollZoomer::updateScrollBars() ()
#5 0x000000000041d162 in ftuPlot::ftuPlot(QwtText, QWidget*) ()
#6 0x0000000000416099 in waveform::waveform(QWidget*) ()
#7 0x000000000040f280 in ftuGui::ftuGui(QWidget*) ()
#8 0x000000000040ed9e in main ()
(gdb) bt
#0 0x00007f6ad6535020 in QwtScaleDraw::getBorderDistHint(QFont const&, int&, int&) const () from /usr/lib/libqwt.so.6
#1 0x00007f6ad65747d6 in QwtScaleWidget::getBorderDistHint(int&, int&) const () from /usr/lib/libqwt.so.6
#2 0x00007f6ad654fd21 in QwtPlot::updateAxes() () from /usr/lib/libqwt.so.6
#3 0x00007f6ad654a90a in QwtPlot::replot() () from /usr/lib/libqwt.so.6
#4 0x0000000000416f70 in ScrollZoomer::updateScrollBars() ()
#5 0x000000000041d162 in ftuPlot::ftuPlot(QwtText, QWidget*) ()
#6 0x0000000000416099 in waveform::waveform(QWidget*) ()
#7 0x000000000040f280 in ftuGui::ftuGui(QWidget*) ()
#8 0x000000000040ed9e in main ()
To copy to clipboard, switch view to plain text mode
If I do it like the example
{
return new ftuTransformation();
}
QwtScaleTransformation *ftuScaleEngine::transformation() const
{
return new ftuTransformation();
}
To copy to clipboard, switch view to plain text mode
it works without problems.
Well... is there a reason for always returning a new Transformation?
...and on the other hand, is it a good or bad idea, to make the pointer to the container an attribute of MyTransformation?
Thank you and best regards
Bookmarks