[Lazarus] spinedit issue with qt5

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

[Lazarus] spinedit issue with qt5

Free Pascal - Lazarus mailing list
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;


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
--
_______________________________________________
Lazarus mailing list
[hidden email]
https://lists.lazarus-ide.org/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] spinedit issue with qt5

Free Pascal - Lazarus mailing list
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
--
_______________________________________________
Lazarus mailing list
[hidden email]
https://lists.lazarus-ide.org/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] spinedit issue with qt5

Free Pascal - Lazarus mailing list
El 11/06/18 a les 11:30, Luca Olivetti via Lazarus ha escrit:

> 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;
>
And it still fails :-(
If I use -MaxInt and MaxInt it works (albeit with a reduced range)


Bye
--
Luca Olivetti
Wetron Automation Technology http://www.wetron.es/
Tel. +34 93 5883004 (Ext.3010)  Fax +34 93 5883007
--
_______________________________________________
Lazarus mailing list
[hidden email]
https://lists.lazarus-ide.org/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] spinedit issue with qt5

Free Pascal - Lazarus mailing list
On 11.06.2018 11:43, Luca Olivetti via Lazarus wrote:

> El 11/06/18 a les 11:30, Luca Olivetti via Lazarus ha escrit:
>
>> 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;
>>
> And it still fails :-(
> If I use -MaxInt and MaxInt it works (albeit with a reduced range)
>

Please open an issue and attach example project.

zeljko
--
_______________________________________________
Lazarus mailing list
[hidden email]
https://lists.lazarus-ide.org/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] spinedit issue with qt5

Free Pascal - Lazarus mailing list
In reply to this post by Free Pascal - Lazarus mailing list
El 11/06/18 a les 11:43, Luca Olivetti via Lazarus ha escrit:

> El 11/06/18 a les 11:30, Luca Olivetti via Lazarus ha escrit:
>
>> 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;
>>
> And it still fails :-(
> If I use -MaxInt and MaxInt it works (albeit with a reduced range)

Ok, QSpinBox_setMinimum/setMaximum accept an integer parameter, so
-MaxInt and MaxInt is the correct range.

Bye
--
Luca Olivetti
Wetron Automation Technology http://www.wetron.es/
Tel. +34 93 5883004 (Ext.3010)  Fax +34 93 5883007
--
_______________________________________________
Lazarus mailing list
[hidden email]
https://lists.lazarus-ide.org/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] spinedit issue with qt5

Free Pascal - Lazarus mailing list
In reply to this post by Free Pascal - Lazarus mailing list
El 11/06/18 a les 11:49, zeljko ha escrit:

> On 11.06.2018 11:43, Luca Olivetti via Lazarus wrote:
>> El 11/06/18 a les 11:30, Luca Olivetti via Lazarus ha escrit:
>>
>>> 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;
>>>
>> And it still fails :-(
>> If I use -MaxInt and MaxInt it works (albeit with a reduced range)
>>
>
> Please open an issue and attach example project.

Done

https://bugs.freepascal.org/view.php?id=33850

Bye
--
Luca Olivetti
Wetron Automation Technology http://www.wetron.es/
Tel. +34 93 5883004 (Ext.3010)  Fax +34 93 5883007
--
_______________________________________________
Lazarus mailing list
[hidden email]
https://lists.lazarus-ide.org/listinfo/lazarus