Recent

Author Topic: Strange behavior in Qt5/MDI project [SOLVED]  (Read 3156 times)

fmolina

  • New Member
  • *
  • Posts: 43
Strange behavior in Qt5/MDI project [SOLVED]
« on: August 17, 2020, 06:13:01 pm »
Hi,
I'm trying to setup an MDI project (in fact, porting a Delphi one) using spreadsheetgrids rather extensively. Lazarus/win32 MDI projects do not work well, and I found somewhere in the Forum that qt5 supports MDI. So I have prepared the attached project, compiled with the qt5 widgetset. I copied the required dll's to the project folder for simplicity (from qt 5.6.2 and mingw latest version). Runinng the program, clicking the button in main window creates an MDIChild one. Iit behaves well in the sense that minimizing the child window it remains within the main one as expected. But here the TSWorkshhetGrid shows a strange problem: go to any cell, type some text and press Enter: the text disappears. Press Enter again and the text will appear in the cell below.
This thing does not happen if I compile the project with the win32 widgetset, but there the MDI project does not behave correctly. I need the MDI environment for my project. What to do?

Lazarus 2.0.10 r63526 FPC 3.2.0 x86_64-win64-win32/win64 on windows 10 64 bits up to date.

Thanks
Fernando
« Last Edit: September 06, 2020, 12:47:16 am by fmolina »

wp

  • Hero Member
  • *****
  • Posts: 13571
Re: Strange behavior in Qt5/MDI project
« Reply #1 on: August 17, 2020, 07:34:28 pm »
A similar issue has been reported in bugtracker (https://bugs.freepascal.org/view.php?id=36824), but I don't have a solution for it so far.

fmolina

  • New Member
  • *
  • Posts: 43
Re: Strange behavior in Qt5/MDI project
« Reply #2 on: August 19, 2020, 06:41:57 pm »

wp

  • Hero Member
  • *****
  • Posts: 13571
Re: Strange behavior in Qt5/MDI project
« Reply #3 on: September 03, 2020, 11:54:03 pm »
Please try r7642. It should work now, at least it does in my tests.

fmolina

  • New Member
  • *
  • Posts: 43
Re: Strange behavior in Qt5/MDI project
« Reply #4 on: September 04, 2020, 02:19:20 am »
Thank you. But ... sorry, I cannot find r7642. I downloaded the lazarus SVN but cannot find fpspreadsheet

wp

  • Hero Member
  • *****
  • Posts: 13571
Re: Strange behavior in Qt5/MDI project
« Reply #5 on: September 04, 2020, 11:29:34 am »
fpspreadsheet is not part of the Lazarus distribution. It has its own svn inside the Lazarus Components and Code Repository (CCR, https://sourceforge.net/p/lazarus-ccr/svn/HEAD/tree/components/fpspreadsheet/).

Three possible ways to get the new version

(1) If you have svn you should checkout the svn repository, see the information on the page mentioned.

(2) If you do not use svn you can download the snapshot from the same site ("Download snapshot").

(3) Or, if you want to keep your current version, you can modify the fpspreadsheet soures yourself -- it's not so much:
  • Load file fpspreadsheetgrid.pas (in folder source/visual of the fpspreadsheet installation)
  • In the interface section, delete the method TsCustomWorksheetGrid.EditingDone and add a new method TsCustomWorksheet.EditorDoGetValue; it must be in the protected section and declared as "override":
Code: Pascal  [Select][+][-]
  1. type
  2.   TsCustomWorksheetGrid = class(TCustomWorksteet)
  3.   ...
  4.   protected
  5.     ...
  6.     procedure EditorDoGetValue; override;    // <---- ADD
  7.     ...
  8.   public
  9.     ...
  10.     //procedure EditingDone; override;   // <--- REMOVE
  11.     ...
  12.   end;
  • In the implementation section delete the code for TsCustomWorksheetgrid.EditingDone and add the following code
Code: Pascal  [Select][+][-]
  1. procedure TsCustomWorksheetGrid.EditorDoGetValue;
  2. var
  3.   cell: Pcell;
  4. begin
  5.   if (Editor<>nil) and Editor.Visible and (FOldEditorText <> FEditText) then
  6.   begin
  7.     cell := Worksheet.GetCell(GetWorksheetRow(Row), GetWorksheetCol(Col));
  8.     if Worksheet.IsMerged(cell) then
  9.       cell := Worksheet.FindMergeBase(cell);
  10.     if (FEditText <> '') and (FEditText[1] = '=') then
  11.       Worksheet.WriteFormula(cell, Copy(FEditText, 2, Length(FEditText)), true)
  12.     else
  13.       Worksheet.WriteCellValueAsString(cell, FEditText);
  14.     FEditText := '';
  15.     FOldEditorText := '';
  16.   end;
  17.   inherited;
  18. end;
 



fmolina

  • New Member
  • *
  • Posts: 43
Re: Strange behavior in Qt5/MDI project
« Reply #6 on: September 04, 2020, 01:29:35 pm »
Thank you! I'll go for #3, and let you know the results. It will take a few days, I'm very busy now.

fmolina

  • New Member
  • *
  • Posts: 43
Re: Strange behavior in Qt5/MDI project
« Reply #7 on: September 05, 2020, 05:42:31 pm »
Hi Werner,
I am afraid it is not completely solved.
I edited  fpspreadsheetgrid.pas as in your message, clean and build, & run. In my test:
1. I type some text in any cell.
2. Press return or up/down/right keys, the text remains ok in the cell.
3. But, if in the new cell I press any of these keys again, the text appears repeated.
Should I post this in the bugtracker also?
Regards

wp

  • Hero Member
  • *****
  • Posts: 13571
Re: Strange behavior in Qt5/MDI project
« Reply #8 on: September 05, 2020, 07:37:53 pm »
Yes please, because the issue obviously is not yet fully solved.

(My problem is: I cannot reproduce this behaviour -- but let's continue the discussion in the bug tracker).

 

TinyPortal © 2005-2018