[Lazarus] spinedit issue with qt5

Luca Olivetti luca at wetron.es
Mon Jun 11 11:30:07 CEST 2018


El 11/06/18 a les 11:14, Luca Olivetti via Lazarus ha escrit:
> Lazarus 1.8.4, FPC 3.0.4, x86_64-linux-qt5
> 
> In a spinedit, if I set maxvalue and minvalue to 0, the spinedit doesn't 
> work with the qt5 widgetset.
> 
> I see that in qtswsspin.pp
> 
>      if (ACustomFloatSpinEdit.MaxValue > ACustomFloatSpinEdit.MinValue) 
> then
>      begin
>        ASpinWidget.setMinimum(ACustomFloatSpinEdit.MinValue);
>        ASpinWidget.setMaximum(ACustomFloatSpinEdit.MaxValue);
>      end
>      else
>      begin
>        ASpinWidget.setMinimum(-MaxDouble);
>        ASpinWidget.setMaximum(MaxDouble);
>      end;
> 

I changed that to

     if (ACustomFloatSpinEdit.MaxValue > ACustomFloatSpinEdit.MinValue) then
     begin
       ASpinWidget.setMinimum(ACustomFloatSpinEdit.MinValue);
       ASpinWidget.setMaximum(ACustomFloatSpinEdit.MaxValue);
     end
     else
     begin
       if ASpinWidget is TQtFloatSpinBox then
       begin
         ASpinWidget.setMinimum(-MaxDouble);
         ASpinWidget.setMaximum(MaxDouble);
       end else
       begin
         ASpinWidget.setMinimum(-$7fffffffffffffff);
         ASpinWidget.setMaximum($7fffffffffffffff);
       end;
     end;


> 
> so at first sight it seems it should work, but the implementation of 
> setMinimum and setMaximum is
> 
> 
> procedure TQtSpinBox.setMinimum(const v: Double);
> begin
>    QSpinBox_setMinimum(QSpinBoxH(Widget), round(v));
> end;
> 
> procedure TQtSpinBox.setMaximum(const v: Double);
> begin
>    QSpinBox_setMaximum(QSpinBoxH(Widget), round(v));
> end;
> 
> 
> 
> and, while round(-MaxDouble) works, round(MaxDouble) silently fails 
> (linux/x64, it gives an FPE exception under win32).
> 
> There's no such problem with gtk2 because the underlying widget is 
> floating point based.
> 
> 
> Bye


-- 
Luca Olivetti
Wetron Automation Technology http://www.wetron.es/
Tel. +34 93 5883004 (Ext.3010)  Fax +34 93 5883007


More information about the Lazarus mailing list