Lazarus

Programming => Widgetset => QT => Topic started by: AFFRIZA 亜風実 on May 30, 2022, 02:29:33 am

Title: (solved) Translucent Window in Qt but the anchor doesn't work properly
Post by: AFFRIZA 亜風実 on May 30, 2022, 02:29:33 am
So, I just playing with Qt5 to make window translucent. Since the Lazarus's Alpha Blend property makes everything translucent so I using Qt5 functions directly to do that. Here's the code:
Code: Pascal  [Select][+][-]
  1. procedure TForm1.FormCreate(Sender: TObject);
  2. begin
  3.  
  4.   QWidget_setVisible(TQtMainWindow(Self.Handle).GetContainerWidget, false);
  5.   TQtWidget(Panel1.Handle).setParent(TQtMainWindow(Self.Handle).Widget);
  6.   QWidget_setAttribute(TQtMainWindow(Self.Handle).Widget, QtWA_TranslucentBackground);
  7.   Panel1.Align:=alClient;
  8.  
  9. end;
  10.  
But, when I resized the window, something is strange the panel that I've set to use alClient didn't resize when I resized the window. Strangely, when I move the window it resized, the action is kinda late (I guess?). May someone know to make that to behave normally in translucent window?  :-[

Anyway, I don't know if the ContainerWidget also can be set as translucent. Now, by doing that is translucent as well.
Here's the change:  :D
Code: Pascal  [Select][+][-]
  1. procedure TForm1.FormCreate(Sender: TObject);
  2. begin
  3.   QWidget_setAttribute(TQtMainWindow(Self.Handle).Widget, QtWA_TranslucentBackground);
  4.   QWidget_setAttribute(TQtMainWindow(Self.Handle).GetContainerWidget, QtWA_TranslucentBackground);
  5. end;
  6.  
Title: Re: Translucent Window in Qt but the anchor doesn't work properly
Post by: zeljko on May 30, 2022, 11:06:07 am
Please attach complete example project.
Title: Re: Translucent Window in Qt but the anchor doesn't work properly
Post by: AFFRIZA 亜風実 on May 30, 2022, 12:51:39 pm
Please attach complete example project.
Hello, zeljko. Thanks for the reply.

Here's the example.
Title: Re: (solved) Translucent Window in Qt but the anchor doesn't work properly
Post by: AFFRIZA 亜風実 on May 31, 2022, 08:37:44 am
Anyway, I don't know if the ContainerWidget also can be set as translucent. Now, by doing that is translucent as well.
Here's the change:  :D
Code: Pascal  [Select][+][-]
  1. procedure TForm1.FormCreate(Sender: TObject);
  2. begin
  3.   QWidget_setAttribute(TQtMainWindow(Self.Handle).Widget, QtWA_TranslucentBackground);
  4.   QWidget_setAttribute(TQtMainWindow(Self.Handle).GetContainerWidget, QtWA_TranslucentBackground);
  5. end;
  6.  

Why I didn't thinking about doing this before  :'(
TinyPortal © 2005-2018