Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2018-06

spinedit issue with qt5

6 messages · 2 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Luca Olivetti

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

Reply by email

Luca Olivetti
to Luca Olivetti

El 11/06/18 a les 11:14, Luca Olivetti via Lazarus ha escrit:

Show quoted text 19 lines
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;
Show quoted text 25 lines
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

Reply by email

Luca Olivetti
to Luca Olivetti

El 11/06/18 a les 11:30, Luca Olivetti via Lazarus ha escrit:

Show quoted text 21 lines
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

Reply by email

zeljko
to Luca Olivetti
Luca Olivetti wrote 26 lines
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

Reply by email

Luca Olivetti
to Luca Olivetti: El 11/06/18 a les 11:30, Luca Olivetti via Lazarus ha escrit: And it still fails :-( If I…

El 11/06/18 a les 11:43, Luca Olivetti via Lazarus ha escrit:

Show quoted text 25 lines
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

Reply by email

Luca Olivetti
to zeljko: Please open an issue and attach example project. zeljko

El 11/06/18 a les 11:49, zeljko ha escrit:

Show quoted text 29 lines
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

Reply by email