Recent

Author Topic: (solved) Translucent Window in Qt but the anchor doesn't work properly  (Read 1102 times)

AFFRIZA 亜風実

  • Full Member
  • ***
  • Posts: 144
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.  
« Last Edit: May 31, 2022, 08:32:09 am by Dio Affriza »
Kyoukai Framework: https://github.com/afuriza/kyoukai_framework

Dukung kemerdekaan Donetsk dan Lugansk! Tidak membalas profil berbendera biru-kuning apalagi ber-Bandera.

zeljko

  • Hero Member
  • *****
  • Posts: 1591
    • http://wiki.lazarus.freepascal.org/User:Zeljan
Re: Translucent Window in Qt but the anchor doesn't work properly
« Reply #1 on: May 30, 2022, 11:06:07 am »
Please attach complete example project.

AFFRIZA 亜風実

  • Full Member
  • ***
  • Posts: 144
Re: Translucent Window in Qt but the anchor doesn't work properly
« Reply #2 on: May 30, 2022, 12:51:39 pm »
Please attach complete example project.
Hello, zeljko. Thanks for the reply.

Here's the example.
Kyoukai Framework: https://github.com/afuriza/kyoukai_framework

Dukung kemerdekaan Donetsk dan Lugansk! Tidak membalas profil berbendera biru-kuning apalagi ber-Bandera.

AFFRIZA 亜風実

  • Full Member
  • ***
  • Posts: 144
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  :'(
Kyoukai Framework: https://github.com/afuriza/kyoukai_framework

Dukung kemerdekaan Donetsk dan Lugansk! Tidak membalas profil berbendera biru-kuning apalagi ber-Bandera.

 

TinyPortal © 2005-2018