Recent

Author Topic: How to dock forms into a MainForm Window (qt5) under windows?  (Read 1461 times)

LeoBruno

  • Jr. Member
  • **
  • Posts: 61
How to dock forms into a MainForm Window (qt5) under windows?
« on: August 10, 2022, 01:55:55 pm »
Hi:

I want the main form to be a container for children forms.

I'm trying to achieve this using the following code:

Code: Pascal  [Select][+][-]
  1.     if not (Assigned(FViewPermissoesModulos)) then
  2.       FViewPermissoesModulos := TViewAtributoProjetoPermissoesModulos.Create(Self);
  3.  
  4.     FViewPermissoesModulos.Dock(panel1, panel1.ClientRect);
  5.     FViewPermissoesModulos.BorderStyle := bsNone;
  6.     FViewPermissoesModulos.Align := alClient;
  7.     FViewPermissoesModulos.Show;  
  8.  

It´s not working:

1 - The form is not docked to the panel1
2 - The created form has the border with the close icon

How can I achieve the goal?

thank's
Lazarus 2.2.2 FPC 3.2.2 Windows (qt5) Anchor Docking

LeoBruno

  • Jr. Member
  • **
  • Posts: 61
Re: How to dock forms into a MainForm Window (qt5) under windows?
« Reply #1 on: August 10, 2022, 06:29:46 pm »
Tryied with

Code: Pascal  [Select][+][-]
  1.  
  2.     if not (Assigned(FViewPermissoesModulos)) then
  3.       FViewPermissoesModulos := TViewAtributoProjetoPermissoesModulos.Create(Self);
  4.  
  5.     FViewPermissoesModulos.ManualDock(panel1);
  6.     FViewPermissoesModulos.BorderStyle := bsNone;
  7.     FViewPermissoesModulos.Align := alClient;
  8.     FViewPermissoesModulos.Show;
  9.  
  10.  

it also didn't work
Lazarus 2.2.2 FPC 3.2.2 Windows (qt5) Anchor Docking

zamtmn

  • Hero Member
  • *****
  • Posts: 593
Re: How to dock forms into a MainForm Window (qt5) under windows?
« Reply #2 on: August 10, 2022, 07:33:15 pm »
Dock to TAnchorDockPanel?
see https://gitlab.com/freepascal.org/lazarus/lazarus/-/issues/37165 there is an example there

LeoBruno

  • Jr. Member
  • **
  • Posts: 61
Re: How to dock forms into a MainForm Window (qt5) under windows?
« Reply #3 on: August 10, 2022, 11:05:01 pm »
Thnak you for the answer.

It worked.


Dock to TAnchorDockPanel?
see https://gitlab.com/freepascal.org/lazarus/lazarus/-/issues/37165 there is an example there
Lazarus 2.2.2 FPC 3.2.2 Windows (qt5) Anchor Docking

LeoBruno

  • Jr. Member
  • **
  • Posts: 61
Re: How to dock forms into a MainForm Window (qt5) under windows?
« Reply #4 on: August 10, 2022, 11:06:30 pm »
Just to be clear, because someone might need this...

The following code works with win32 widget, just doesn't work with qt5

Tryied with

Code: Pascal  [Select][+][-]
  1.  
  2.     if not (Assigned(FViewPermissoesModulos)) then
  3.       FViewPermissoesModulos := TViewAtributoProjetoPermissoesModulos.Create(Self);
  4.  
  5.     FViewPermissoesModulos.ManualDock(panel1);
  6.     FViewPermissoesModulos.BorderStyle := bsNone;
  7.     FViewPermissoesModulos.Align := alClient;
  8.     FViewPermissoesModulos.Show;
  9.  
  10.  

it also didn't work
Lazarus 2.2.2 FPC 3.2.2 Windows (qt5) Anchor Docking

LeoBruno

  • Jr. Member
  • **
  • Posts: 61
Re: How to dock forms into a MainForm Window (qt5) under windows?
« Reply #5 on: August 13, 2022, 01:48:11 am »
I came in to an issue that is probably a bug.

When a form get's docked, the main form (the dock panel parent), starts to asume the merhods assigned to the docked form Notify events.

For instance.

I inteded to prevent the docked form from closing.
So at the FormCloseQuery event, I assigned the value false to the CanClose var.

Initially I was under the impression that it worked, but when I tryied to close the main form, I couldn't do it.

For testing purposes, I assigned a showmessage, passing Self.Name to see what was going on, and the message showed the name of the main form when it should have showed the name of the parent form. (trying to close the parent form).

Very strange unwanted behaviour.
Lazarus 2.2.2 FPC 3.2.2 Windows (qt5) Anchor Docking

PascalDragon

  • Hero Member
  • *****
  • Posts: 5444
  • Compiler Developer
Re: How to dock forms into a MainForm Window (qt5) under windows?
« Reply #6 on: August 31, 2022, 09:00:31 am »
For testing purposes, I assigned a showmessage, passing Self.Name to see what was going on, and the message showed the name of the main form when it should have showed the name of the parent form. (trying to close the parent form).

From how I read your message both forms are one and the same. Further up you said that the main form is the one containing the TAnchorDockPanel, but now you also mention a parent, but the parent can only be the form containing the TAnchorDockPanel aka the main form. So what is it now? Maybe use class names to avoid confusing instead of saying “the form that contains this” or “the form that is the parent”.

zeljko

  • Hero Member
  • *****
  • Posts: 1591
    • http://wiki.lazarus.freepascal.org/User:Zeljan
Re: How to dock forms into a MainForm Window (qt5) under windows?
« Reply #7 on: August 31, 2022, 01:48:40 pm »
Better create simple project which describes problem (eg MainForm + Panel + Form which should be docked to panel) and attach here so I'll take a look.

 

TinyPortal © 2005-2018