@@ -841,9 +841,9 @@ void QgsRasterHistogramWidget::on_btnHistoMax_toggled()
841841
842842// local function used by histoPickerSelected(), to get a rounded picked value
843843// this is sensitive and may not always be correct, needs more testing
844- QString findClosestTickVal ( double target, QwtScaleDiv * scale, int div = 100 )
844+ QString findClosestTickVal ( double target, const QwtScaleDiv * scale, int div = 100 )
845845{
846- if ( scale == NULL ) return " " ;
846+ if ( ! scale ) return " " ;
847847
848848 QList< double > minorTicks = scale->ticks ( QwtScaleDiv::MinorTick );
849849 QList< double > majorTicks = scale->ticks ( QwtScaleDiv::MajorTick );
@@ -875,17 +875,26 @@ QString findClosestTickVal( double target, QwtScaleDiv * scale, int div = 100 )
875875
876876void QgsRasterHistogramWidget::histoPickerSelected ( const QPointF & pos )
877877{
878- if ( btnHistoMin->isChecked () )
878+ if ( btnHistoMin->isChecked () || btnHistoMax-> isChecked () )
879879 {
880- leHistoMin->setText ( findClosestTickVal ( pos.x (), mpPlot->axisScaleDiv ( QwtPlot::xBottom ) ) );
881- applyHistoMin ();
882- btnHistoMin->setChecked ( false );
883- }
884- else if ( btnHistoMax->isChecked () )
885- {
886- leHistoMax->setText ( findClosestTickVal ( pos.x (), mpPlot->axisScaleDiv ( QwtPlot::xBottom ) ) );
887- applyHistoMax ();
888- btnHistoMax->setChecked ( false );
880+ #if defined(QWT_VERSION) && QWT_VERSION>=0x060100
881+ const QwtScaleDiv * scale = &mpPlot->axisScaleDiv ( QwtPlot::xBottom );
882+ #else
883+ const QwtScaleDiv * scale = mpPlot->axisScaleDiv ( QwtPlot::xBottom );
884+ #endif
885+
886+ if ( btnHistoMin->isChecked () )
887+ {
888+ leHistoMin->setText ( findClosestTickVal ( pos.x (), scale ) );
889+ applyHistoMin ();
890+ btnHistoMin->setChecked ( false );
891+ }
892+ else if ( btnHistoMax->isChecked () )
893+ {
894+ leHistoMax->setText ( findClosestTickVal ( pos.x (), scale ) );
895+ applyHistoMax ();
896+ btnHistoMax->setChecked ( false );
897+ }
889898 }
890899 if ( QApplication::overrideCursor () )
891900 QApplication::restoreOverrideCursor ();
0 commit comments